How do I integrate mSpec & ReSharper 7.0 in Visual Studio 11? - visual-studio

I've been trying to get these beta programs to work together. Resharper 7.0.3.261 runs just fine. After a nuget install of machine.specifications, I run the InstallResharperRunner.7.0 - VS2011.bat file which copies the mspec dll and resharperRunner dll to the correct plugins folder in my profile.
Now, whenever I create a new project (Mvc 3 or 4) resharper load throws the following error:
Initial instantiation of the component TypeComponent { MSpecUnitTestPresenter, State: Corrupted } has failed. Exception has been thrown by the target of an invocation. Could not load type 'JetBrains.ReSharper.Features.Common.TreePsiBrowser.TreeModelBrowserPresenter' from assembly 'JetBrains.ReSharper.Features.Common, Version=7.0.1.47, Culture=neutral, PublicKeyToken=1010a0d8d6380325'.
I've eliminated the possibility of corruption in the downloaded components by downloading several times, even compiling the mspec 7.0 runner and core dll from source. All variations result in the same error.
I know it's not reasonable to expect error free integration between beta projects - just wondering if someone else has run into this. My objective is just to get mspec working in VS11, and the resharper runner seemed like a reasonable option. Has anyone had success getting mspec to play nicely with VS11 Beta?

Related

VSTS CI build errors on CodedUI test for missing references

We are using VSTS to perform Continuous Integration utilizing a build template that was created to deploy a website to a Dev machine.
This worked fine but then we wanted to add in CodedUI tests to the build template in order to run the tests as part of the build step.
So I added a Visual Studio Test step to the build and added in the test by referencing the test plan and test suite it was associated with.
I made sure the codedUI project was built within the same solution as the website in order to make sure the binaries were built with it.
The problem I'm getting is that when the build runs it brings back errors stating that it is missing the relevant references for the code to work such as:
QualityTools.CodedUITestFramework
QualityTools.Common
TestTools.UITesting
etc.
However these reference are included in the project and "Copy Local" is set to true.
Does anyone have any idea what could be going wrong?
UPDATE
New error received:
MSTestAdapter failed to discover tests in class
'Email_Regression.CodedUITest1' of assembly
'C:\agent_work\4\s\Microservices\Email\Email
Regression\obj\Release\Email Regression.dll'. Reason Could not load
file or assembly
'Microsoft.VisualStudio.QualityTools.CodedUITestFramework,
Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or
one of its dependencies. The system cannot find the file specified..
No test is available in C:\agent_work\4\s\Microservices\Email\Email
Regression\bin\Release\Email Regression.dll
C:\agent_work\4\s\Microservices\Email\Email
Regression\obj\Release\Email Regression.dll. Make sure that test
discoverer & executors are registered and platform & framework version
settings are appropriate and try again.
After talking to the Microsoft help team it appears that you need to have Visual Studio Enterprise edition installed on the machine you wish to run the codedUI tests on.
Update
After discussions with Microsoft and highlighting this being a rubbish solution they are now going to deliver the dll's as part of the new vsTestPlatform installer. I'm not saying this is down to my complaints, just coincidental timing.

How to resolve Lock file error? "...contains msbuild projects but there is no export file"

I am running visual studio Community 2015 Update 3. I have a solution that has been compiling fine but is now generating an error when I try to compile it. The error is
Lock file Microsoft.DotNet.ProjectModel.Graph.LockFile contains msbuild projects but there is no export file
This error is displayed in the Error List window when I compile the solution and the error list indicates that it relates to a project in the solution which is an .Net Core Library that houses my xUnit tests.
The error information indicates that the error is on line 262 of C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets
Screenshot of that location selected below:
The solution contains:
____Asp.Net Core project targeting net461
____Windows Library Project targeting .Net Framework
____ A 2nd Windows Library Project targeting .Net Framework 4.61
____A .Net Core Libary Project targeting net461 (used holding XUnit Tests)
If I try to compile each project individually, they all compile fine except for the project holding the xUnit Tests that generates this error.
The Big Question
So what does "Lock file Microsoft.DotNet.ProjectModel.Graph.LockFile contains msbuild projects but there is no export file" mean? And how can I fix it?
Posting how I got past this error in case it helps others. Ultimately this issue was solved by removing all the projects from the solution, adding them back one by one and then reestablishing the project references. I would attribute the root issue to the .net core preview2 tooling still being flaky.
I had a similar problem, not with the build inside Visual Studio, but with msbuild. For a long time I was sure that the error was caused by dotnet tooling beeing in a preview state, but finally came upon, that one xproj-project wasn't build before another xproj-project, that was dependent of the first one. So I started looking for solutions to build-order problems instead, and came across an old blog-post by Victor Sergienko
http://victorsergienko.com/project-dependencies-of-visual-studio-2008-broken-in-msbuild/
that solved the problem by adding a dependency from the second project to the first like this:
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ProjectOne", "ProjectOne.xproj", "{CAF36C07-36C7-4842-A2DA-9737005D2835}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ProjectTwo", "ProjectTwo.xproj", "{82875D1E-3F13-430B-8946-C26E08BD9DF9}"
ProjectSection(ProjectDependencies) = postProject
{CAF36C07-36C7-4842-A2DA-9737005D2835} = {CAF36C07-36C7-4842-A2DA-9737005D2835}
EndProjectSection
EndProject
Now my solution builds in TeamCity again... finally!

Visual Studio FsUnit test setup - Exception NUnit.Engine.NUnitEngineException

I am using Visual Studio 2013, installed FsUnit 2.2.0, which requires NUnit 3.2.1 and FSharpCore 3.1. I created a separate test project and put a testfixture and test in there. My platform is x64 Win 10. The config is for 'AnyCPU' and 'Debug'. I've tried test settings for x86 and x64. When trying to build and create tests, I get:
------ Discover test started ------
NUnit Adapter 3.2.0.0: Test discovery starting
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\Users\Dad\Documents\Visual Studio 2013\Projects\...
Cannot run tests in process - a 32 bit process is required.
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\Users\Dad\Documents\Visual Studio 2013\Projects\...
Cannot run tests in process - a 32 bit process is required.
NUnit Adapter 3.2.0.0: Test discovery complete
========== Discover test finished: 0 found (0:00:00.1230077) ==========
If I change the config for both the test and target projects to 'x86' (instead of AnyCPU) then the error for the base project goes away, but the same thing happens for the test project.
No tests are ever discovered, help please ... and many thanks!
You will need to remove nunit from your solution and install it again with "NUnit3TestAdapter", version 3.0.10 works.
Uninstall any NUnit software in add/remove program and in your solutions. Now using Nuget package manager (tools > NuGet Package Manager > Manage NuGet Packages for solution...) remove any NUnit you have in a solution and install older version (e.g. 3.0.1). Find "NUnit3TestAdapter" and install in version 3.0.10.
I had the same problem with my .NET Core 2.0 project with NUnit 3.9 in Visual Studio 2017 and tests were not showing up in TestExplorer. Was stuck with this for quite some time. None of the solutions suggested in other related questions worked.
Then I figured out from this link that a class library with target .NET Standard does not work. The test project has to target .NET Core. Also, Microsoft.NET.Test.Sdk NuGet is required.
So, the steps are
Make sure that the test project targets .NET Core
Install latest NUnit NuGet (I used 3.9)
Install corresponding NUnitAdapter NuGet (I used NUnit3Adapter)
Install Microsoft.NET.Test.Sdk NuGet
Re-build and your tests will appear in Test Explorer in Visual Studio.
Note: Already added this answer to another .NET Core specific question. Adding here too, as the solution might be helpful in this scenario as well.
There is an error in NUnit 3.2.1 whereby the TestEngine assumes that it can't run a test requiring 32-bit execution in process. The assumption is always valid for NUnit's own runners, but not necessarily when the process is started by some other program. There's an issue filed about this.

Error when running MSpec - how do I troubleshoot?

I am following this guide to installing and using MSpec, but at the step where he runs MSpec for the first time, I get the following error:
Could not load file or assembly 'file:///[...]\Nehemiah\Nehemiah.Specs\bin\Debug\Nehemiah.Specs.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
I have - to my knowledge - done everything more or less exactly like he did up to this step, except where differences arise because he's using VS2008 and I'm using VS2010, and everything has worked so far. The project Nehemijah.Specs (and the entire solution) builds without problem, both in Visual Studio and on my build server, and I can't find anything useful in Event Viewer (although I might not be looking in the right place here...)
What to do?
It appears you're compiling the Nehemiah.Specs.dll assembly against the .NET Framework 4. In order to run your specifications you need the .NET 4 build of MSpec which contains a console runner (mspec.exe) that is suitable for this version of the framework. You can find the a zip file containing the build on CodeBetter's CI server.
Other possibilities of running .NET 4 spec assemblies are
TestDriven.Net 3.0
ReSharper 5.0
Runners for both tools are also included in the distribution.

NUnit tests in a separate project, same solution

I have a solution containing my main project and a test project using NUnit. Everything compiles but when I run NUnit I get the exception below after the tests load, and the tests fail. I've added the main project as a reference, and I have $(ProjectDir)bin/Debug/$(TargetName)$(TargetExt) in the arguments for NUnit in the external tools setup, with a blank initial directory.
MyMainProjectTests.Database.TestAddDelete:
System.BadImageFormatException : Could not load file or assembly 'MyMainProject,
Version=1.1.1.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. An attempt was made to load a program with an incorrect format.
TearDown : System.Reflection.TargetInvocationException : Exception has been
thrown by the target of an invocation.
----> System.BadImageFormatException : Could not load file or assembly
'ChickenPing, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null' or one
of its dependencies. An attempt was made to load a program with an incorrect
format.
After scouring for hours the only thing I've found is a bug in VS2005 which mentions the /bin and /obj directories, but the answer provided didn't help.
Any solutions?
Instead of setting up NUnit as an External Tool, I set the unit test project as the StartUp project. In the project's Properties screen, set the Start Action to "Start external program" and point it to nunit.exe. In the Start Options section, I specify the test assembly (no path necessary) in the "Command line arguments" box. At this point, simply press F5 to start up NUnit.
Use the nunit-x86.exe instead of nunit.exe as your runner.
A better longer term solution may be to buy ReSharper that includes a much nicer test runner for NUnit that fully integrates into Visual Studio. It auto detects your .NET project type (x68 or x64). ReShaper comes with tons of other features of which unit testing is just one. Their test runner also integrates with their DotCover code coverage analyser.
You may find that you'll need a later version of Visual Studio to use ReSharper. The latest version works with Visual Studio 2013 Community Edition that you can get for free though I understand you may have issues upgrading some project features from such a rather old VS2005 project.
I don't have any affiliation with ReSharper.
Are you running on x64? You will get that error if loading a x64 bit from x86 and vise versa. Also, the path you are trying to create should be the $(TargetPath) macro.
Just set "Platform target" of Tests project to "x86".
Is your main project a .exe or a .dll? Older versions of .NET couldn't reference an .exe, so that might be the problem.
In either case, I'd expect problems if the main assembly didn't end up somewhere accessible by your test assembly (for example, in the same directory). You could check that, and if not make it so, perhaps by having Visual Studio copy the referenced (main) assembly to the local directory.
The "An attempt was made to load a program with an incorrect format." makes me wonder if the "missing assembly" theory is right, but without more info, it's the best guess I can think of.
Go the the NUnit install (example: C:\Program Files (x86)\NUnit 2.6.3\bin) location and open nunit-86.exe.

Resources