Using NUnit from Visual Studio to MonoDevelop - c#

I get this error when I try to run unit tests on a solution originally from Visual Studio: RemotingException: Unix transport error.
I originally let MonoDevelop grab it's own NuGet packages including NUnit 2.6.4, NUnit.Runners 2.6.4, and NUnitTestAdapter 2.0.0. I then tried using the 2.6.3 references included with MonoDevelop and getting rid of NuGet packages including NUnitTestAdapter 2.0.0. I also tried using NUnit 3.0.1. All of these resulted in the same errors. How can I get NUnit to work with this solution?
The project can be found at: https://github.com/ParagonTruss/GeometryClassLibrary

It turns out that when I reinstalled the NUnit Visual Studio Test Adapter in Visual Studio it would change <Private>True</Private> in the .csproj file to <Private>False</Private> and then worked fine in MonoDevelop.

Related

MSBuild fails on Unit Test Project (.NET Core) after NuGet Restore

ISSUE
The Visual Studio Build task in a Visual Studio Team Services build for a solution that contains a default ASP.NET MVC website and a default Unit Test Project is failing to find references. This task runs after a NuGet Restore that should install these references, but even though the NuGet Restore task succeeds, the references are not installed on the server running this build.
Visual Studio Team Services Logs
The error logs have been uploaded to This Github Repository
Attempted Fixes
In an effort to ensure that the packages are properly referenced by the project, all of the NuGet packages were reinstalled from Package Manager using the following command:
PM> Update-Package --reinstall
This only caused MSBuild to not find Microsoft.Net.Compilers.props in both the projects. So in an attempt to correct this, the version of Microsoft.Net.Compilers.props in the project was dropped to version 2.3.2. However, this only brought back the original errors where the MSTest.TestAdapter.props and Microsoft.Net.Compilers.props references could not be found.
Try it with these tasks (works fine for me with the sample solution you shared):
NuGet Tool Installer (Version of NuGet.exe to install: 4.3.0)
NuGet restore (Choose 2.* version)
Visual Studio Build (Visual Studio Version: Latest)
Queue build with the agent that has VS2017 installed.

Using C# 7.1 with MSBuild

To use the new C# 7.1 language features with Visual Studio 2017, you add the setting <LangVersion>latest</LangVersion> to your project file(s).
However, building such projects from MSBuild (version 15.3.409.57025, located at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin) results in an error:
CSC : error CS1617: Invalid option 'latest' for /langversion;
must be ISO-1, ISO-2, Default or an integer in range 1 to 6.
Is this feature just not yet supported by MSBuild, or is it possible to get this working?
This covers 200+ projects that were originally created variously in Visual Studio 2013 and 2015. They were all re-targeted to .NET 4.7 using the Target Framework Migrator tool (which saved lots of clicking and appears - based on inspecting .csproj file changes - to do the job correctly).
The projects all build successfully from Visual Studio 2017.
Nuget packages
Microsoft.Net.Compilers nuget package does not work and needn't to be installed.
Set the following project/build settings
Set at least C# 7.1 or higher in the Debug and Release build properties. (via: Project menu > [ProjectName] Properties > Build tab > [Advanced] button > Language Version).
Setting it to latest does not work.
Also make sure that you are running the latest MSBuild version.
Add a reference to the Microsoft.Net.Compilers package (version 2.3.x, to get C# 7.1).
A short description of the package:
Microsoft.Net.Compilers
This package not only includes the C# and
Visual Basic compilers, it also modifies MSBuild targets so that the
included compiler versions are used rather than any system-installed
versions. Once installed, this package requires Microsoft Build Tools
2015.
Make sure you have changed for "All Configuration" and not just "Debug"
else you will be baffling why it is failing at production.
In case you land here because you get the error as the OP mentioned, running msbuild via command line (e.g. from a build agent such as jenkins), the solution may be as easy as to upgrade Microsoft Build Tools 2015.
You can do that via choco install microsoft-build-tools or manually via the official Microsoft Build Tools 2015 or by updating your Visual Studio 2017 installation.
I've got a solution with a C# console app using C# 7.1 here.
Using the VS 2017 command line (and thus MSBuild 15.3.409.57025) it worked fine. (The .csproj does contain <LangVersion>latest</LangVersion>.)
Is this feature just not yet supported by MSBuild, or is it possible to get this working?
Yes it is.
Which instance of csc.exe is being run and what's its version? Because it looks like, despite quoting the version, you have the wrong version of csc.exe (the error message says 1-6 so not even C# 7 would work).
We discovered that our MVC projects were triggering this issue.
To fix, we updated the Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package used by these projects from version 1.0.0 to 1.0.7.

Visual Studio 2017 web project: can't use C#7

I've created a brand new web project in Visual Studio 2017, but I can't use any C#7 features in this web project. No errors are reported in Visual Studio, but the build fails and this is verified by the output window which shows the CSC task failing.
Here is a project which reproduces the issue.
https://drive.google.com/open?id=0B-mqMIMqm_XHQkxONjRLYzA3SUk
It's an out of the box VS web project with the exception of the addition of the following code in HomeController.cs:
var i = 1_000_000;
This uses _ which is a C#7 feature. Remove this line and the build succeeds.
Non-web projects compile fine with C#7 features, and I've tracked down the difference to a different compiler being used for web projects. Non-web projects use the following compiler:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\csc.exe
Web projects use this compiler:
[Path to solution root]\packages\Microsoft.Net.Compilers.1.3.2\build..\tools\csc.exe
How can I resolve this?
I tried it on my machine and I had the same problem.
The solution is to install the newest Microsoft.Net.Compilers package.
For example by Tools->NuGet package Manager -> Package Manager Console
and then type:
Install-Package Microsoft.Net.Compilers

Visual Studio 2017 Enterprise Add Unit Test project throws Package Installation Error

I have a solution with projects pointing to .Net Framework 4.5 which I have opened in Visual Studio 2017 and tried to Unit Test Project pointing to .Net Framework 4.5. I am getting the following error
Package Installation error .
Could not add all required packages to the project. The following packages failed to install from 'C:\Program Files(x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\502SXCIF.E5I\Packages':
MSTest.TestFramework.1.1.11: Failed to add reference to 'Microsoft.VisualStudio.TestPlatform.TestFramework'
I have tried changing the Platform to x86 as suggested on some online resources.
I am using a Windows 7 Enterprise 64 bit. Has anyone been able to resolve this.
MsUnit test related template got missed in your local system.if you have another version please try to copy respective folder it will resolve the issue.

Unsupported test framework error in NUnit

I am using NUnit testing with Visual Studio 2013. We are using NUnitTestAdapter for integration of test run of NUnit with Visual Studio.
Visual Studio 2013
NUnit is version="3.0.1"
NUnitTestAdapter version="2.0.0"
.Net Framework 4.5.2
All packages are latest & installed from Nuget. There is no build error.
We are getting error in test result window:
Attempt to load assembly with unsupported test framework in D:\JuniorAchievement\Git\jaums\JA.UMS.Tests\bin\Debug\JA.UMS.Tests.dll
while running or debugging test using Visual Studio Test Explorer.
Test is able to run on one machine with same code on Visual Studio 2013 ultimate. We all other have Visual Studio 2013 professional version, although I doubt it has nothing to do with the problem.
Please Help.
Update
__________
After update to NUnit3 Test Adapter no error but still no test are discovered.
Somehow both Adapter are available but with Nuget & VS extension I can find only
NUnit3 Test Adapter.
Installed NUnit3 Test Adapter from https://visualstudiogallery.msdn.microsoft.com/0da0f6bd-9bb6-4ae3-87a8-537788622f2d
It looks like you are trying to run NUnit3 tests with the NUnit2 Test Adapter. This is not supported.
You need to install the NUnit3 Test Adapter through Tools > Extensions and Updates in Visual Studio.
NUnit 3.x.y (NUnit 3.4.1) is compatible with NUnit3TestAdapter 3.x.y (NUnit3TestAdapter 3.4.0)
NUnit 2.x.y (NUnit 2.6.4) is compatible with NUnitTestAdapter 2.x.y (NUnitTestAdapter 2.0.0)
If you use NUnit 3.x.y you have to install NUnit3TestAdapter 3.x.y instead of NUnitTestAdapter 2.x.y
I am using Microsoft Visual Studio Community 2015 and Microsoft .NET Framework 4.x
Steps to follow for installation:
1. Open Visual Studio and create a project
2. Right click on project -> Click on "Manage Nuget Packages..." from context menu
3. From pop up window: Install NUnit 3.x.y and NUnit3TestAdapter 3.x.y
4. Now run your tests
NUnit 3 only runs with NUnit test adapter 3 or latest version since there is compatibility issue with the older version 2.0.
so if you have an exception like this:NUnit VS Adapter 2.0.0.0 discovering tests is started
Attempt to load assembly with unsupported test framework in c:.......
NUnit VS Adapter 2.0.0.0 discovering test is finished
then all you need to do is to install the latest version of NUnit and NUnit test adapter on to your project be right clicking referencence on your solution explorer and manage Nuget packages.
run Install-Package NUnit3TestAdapter -Version 3.10.0 on your Package Manager Console.
Run this package manange console.
PM> Install-Package NUnit3TestAdapter -Version 3.10.0
Make sure that, you have selected the nuget.org in package source dropdown and selected the Test project in Default project dropdown.

Categories

Resources