NCrunch TestProjects with .net standard / core not working - c#

I use ncrunch for my testing environment in vs2017.
In some projects i get a weired exception that projects could not be resolved
To reproduce i do the following steps:
Create a new .net standard 1.4 project
create a .net core xunit test project
In the xunit project we add a reference to the .net standard project
Error:
Quote:
NCrunch: If you are experiencing problems in getting this project to
build, have a look at
http://www.ncrunch.net/d...ng_project-build-issues
..............\vs2017\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets
(92, 5): Cannot find project info for
'C:\Users\BoasE\AppData\Local\NCrunch\50412\8\dev\BLS_UserApi\src\BoundContextes\Subscriptions\ClassLibrary1\ClassLibrary1\ClassLibrary1.csproj'.
This can indicate a missing project reference.
Remarks:
As the descriped problem cost me some time and the exception is not obvious that it is related to a compatibility issue i post this save their time.

Currently .net standard / core is not supported. it is plmaned for begin of march 2017
Please note that NCrunch does not yet support netstandard or .NET core
projects. This is currently a work in progress
https://ncrunch.uservoice.com/forums/245203-feature-requests/suggestions/8065623-support-net-core-net-standard-previously-known

Related

VS update broke the microsoft.analytics.dll

I have a solution with two projects (C# and U-SQL) to run in the Azure Data Factory. I have referenced microsoft.analytics to use some analytics functions.
After the VS update to 15.9.14 on July 9, 2019 the c# project was not building giving the error that the assembly is missing but it was not missing. If I clicked to the error it go away and recognize the assembly. Then I try to build again and same error appears.
So I check the dll and the version was the same as before update but after I opened it with dotPeek I saw that the assembly target framework was changed to 4.7.2.
My project is on 4.5 because of the official azure data factory documentation says that we can run projects only up to framework 4.5 so I can't upgrade to 4.7 or above.
You can see the difference of those dll.
Assemblies location:
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\IDE\PublicAssemblies
So to resolve the problem I froze those dll and added as external references to my project in order to compile and build it and it worked.
If I want to create a new U-SQL project I can only pick 4.7.2.
My question is, how I can run U-SQL projects and analytics assemblies on an framework that is still not supported in the azure data lake?
If the Data Lake now supports 4.7.2 why there is no documentation for it or at least something to let us know?
Is this an VS minor update with a bug?
So after some Microsoft tickets they don't know how to respond to this. They said to try run some methods that are only present in the 4.7.2 framework in the data lake.
So I tried those methods and the jobs didn't run for obvious reasons.
Conclusion:
VS migrated the U-SQL projects to 4.7.2 but we can't run custom c# code for this target framework in the Azure.
Data Lake Analytics runs only 4.5 as said in documentation.
For now our project will remain 4.5.

The target process exited without raising CoreCLR started event error with .NET Core 2.2

I want to debug an empty WebApi Project based on .NET Core 2.2.
I installed the "Core 2.2 SDK x86" and changed the target framework to 2.2:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
When I started to debug this project, IIS starts, but in the route api/values I see nothing (it loads forever) and I get this error:
The target process exited without raising a CoreCLR started event.Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core
In my solution WPF and Class Library projects exist. I wanted to make a WebApi for it. Like I said, it's an empty base project generated by Visual Studio 2019. I just installed Core 2.2. Why do I get that error and what am I doing wrong?
I had the same issue.
I ran Program.cs file from the command line and the error message was different.
So, apparently, I didn't have the appropriate .NET Core runtime installed.
You can download it by the following link - https://dotnet.microsoft.com/download
I was facing the same issue!
I updated my Visual Studios to the most recent via the VS Installer.
While updating, I also added the following VS Workloads:
ASP.NET and web development
.NET desktop development
See about workloads here:
https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/modify-visual-studio.md
This worked for me! 😊
I did not have to downgrade or remove anything
I had to do a "clean" and "rebuild" of the project and after that it worked again.
I ran with the same problem. But for me it was that my project was running in .NET Core 2.2, which I didn't have installed. I'm using VS 2019.
So for the solution, just go to Visual Studio Installer and for your VS 2019 hit "Modify" like in the following image (it's in spanish though):
Then, click "Individual Components", like
And then, make sure you checked in ".NET Core 2.2 Runtime (EOL)" (and above like .NET Core 3.0, if you want) and click "Modify", as shown
Hope this works for you.
In my case, switching to x64 save the day.
It seems like there are lots of different causes for this. For me, it was because I had upgraded a .csproj file but I hadn't updated the image used in my docker file.
I had same issue after package upgrading. You don't need any vs update.
Just go to
dotnet.microsoft.com/download/dotnet-core/2.2
and get runtime
dotnet-hosting-2.2.7-win.
I had the same error. Remove "Microsoft.AspNetCore.All" from dependencies.
I have downgraded "Microsoft.AspNetCore.App" version and error gone .
Deleting all bin folders of my solution
building everything again did the trick for me
(.NET Core 3.1 VS 2019)
I see many answers like try and error
after searching about the issue, I got the following :
it simply depends on three parameters and they have to be compatible
Windows platform "x86,x64" you can change it from the CPU option of the visual studio
or choose any CPU hence the install .net x framework should be compatible with the windows
The target framework for the project
(check the project target framework "right-click on the project and check target framework") if it is 5 so the enabled in the third parameter should be 5 or change this one but take care you should tell the other team members if you change it
The Enabled framework go for tools and get tools and go for individuals component and chose the target framework the same as found in step 2 and press modify
Faced this issue during xUnit testing. Downgrading nuget package "Microsoft.NET.Test.Sdk" to 15.9.0 worked for me
I got this error because of a Project reference pointing to a project, that did not exist anymore (was removed in merged git-commit). Solved it by right-clicking the project, then Edit Project File, delete the reference and save.
I was trying to run a project that used net core 2.2 but I didn't have it, and there was no error(I had 1.1), so after installing the 2.2 using the "Visual Studio Installer" it worked like a charm. =)
I restarted my Visual Studio instance in Admin mode and I was able to debug.
After closing Visual Studio I can now start in normal mode and debug as expected. I'm not sure what changed though.
I was missing a reference to AWSSDK.Core. After installing the specific version and re-starting VS2019 and rebuilding, the project ran fine.
All of a sudden it stopped working. For me clean solution and re-build solution worked.
I was getting a similar error with my project: The target process exited without raising a CoreCLR started event.
My startup project was targeting multiple frameworks: netstandard2.0;netcoreapp2.2
I fixed this issue by changing my target framework from netstandard2.0 to netcoreapp2.2 using the following stackoverflow directions: How to switch between target frameworks for .NET Core projects in Visual Studio
Be sure to install the exact version of .net core that you want your project to run on
I had this issue and finally tracked it down to doing a "publish" operation with a deployment mode of: "Self contained" That resulted in dropping all .NET runtime binaries in my bin directory. Where I think things got totally messed up is I have several solutions all using that same common bin directory, each build different exe's and dll's.
Only one was for a self contained deployment as a test. I think that started mixing up some of the minor dlls for the .NET core and causing this issue. Once I purged all the dll's that were "not mine" and rebuilt things started working again. I'm using Visual Studio 2019 16.8.2 / .NET Core 3.1
I realize the original question is regarding .NET Core 2.2 but this question comes up first when searching for the main issue.
.Net Core 2.2 is required to be installed. I fixed when I added this in Visual Studio Installer.
VS2019 16.7.1 ASP.Net Core 3.1
Our Nunit test projects that issued this error, only worked with a very select set of Nunit and Microsoft packages.
Microsoft.NET.Test.sdk - 16.5
Nunit - 3.12
Nunit3TestAdapter 3.16.1
But here's the catch, you have to go into
c:\users\yourname\.nuget\packages and look for all three folders shown above. If you find any other version in those folders, delete it.
I found two versions in the Microsoft.NET.Test.SDK folder. I suspect the newer version was being loaded. Why? Because when I deleted it everything ran fine.
A corrupt layout is also possible, had this happen myself. To fix, go to projpath\bin\x64\configtype\AppX, for example:
C:\Users\Foo\Documents\Visual Studio 2019\projectname\bin\x64\Debug\AppX
Delete everything here, rebuild and you're good to go.
Since I don't see it here yet, here's what worked for me. I have a UWP project, Win32 project, and Windows application packaging project in the same solution. Running the Win32 app using FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync was giving this message and not working.
What fixed it was changing a setting in the packaging project's project settings:
Debug -> Debugger type -> Background task process: Native Only
I had same issue. Now in VS2022 you cannot download NetCore2.2.
So just download and install NetCore 2.2 from microsoft dotnet website.
https://dotnet.microsoft.com/en-us/download/dotnet/2.2
This error occurred when I tried changing C# projects in my solution to use Docker and running it:
The error went away when I changed the C# projects back to use the Visual Studio's debug server and running it:
In the Test Explorer window of Visual Studio 2019, make sure that there are no references to any *.testsettings or *.runsettings files if you are not using them intentionally. I had referenced a *.testsettings file unintentionally, and that was causing the issue.
For me, I'd just installed Visual Studio 2022 on a fresh installation of Windows 11. My project uses .Net 5, which wasn't installed by default (I only had .Net 6). I simply used the Visual Studio installer, modified my VS2022, selected Individual Components, and enabled .Net 5. Viola!
I started to get this error after updating Visual Studio from 2019 to 2022. It turned out that the project target framework was set to .Net Core 3.1, which was removed when I uninstalled VS2019, and the solution was to change it to .Net 6.0 which is the component I had selected during installation (Installing .Net Core 3.1 from the Visual Studio Installer should work as well).
To do so, right click on the project name and look for the "Target framework" option (my installation is in Spanish so that's what I presume it should say).
I've encountered this issue multiple times, using VS 2017 and VS 2019 across .NET Core 2.1, 3.1 and 5.0.
There are many conditions that can cause this problem to occur:
Microsoft Update can install a version of .Net Core at any time, automatically and outside of your awareness and knowledge.
It can also change the installation of any .Net Core SDK version's installed components.
Your version of VS has to be compatible with the version of the .Net Core SDK that you have installed.
You must have all of the following components installed for this error to be resolved/pre-empted for .NET 5.0 (please check the dotnet 5.0 site for the compatibility list by versions).
Microsoft .NET SDK 5.0.408 which includes (the following below) must all be installed and listed in the control panel:
.NET Core 5.0.17 Windows Desktop Runtime,.NET Runtime, Windows Server Hosting, Shared Framework
If any .NET Core 3.1 SDK are installed without your knowledge, you must uninstall it and repair your targeted .net core version's installation.

The nuget operation failed due to one or more packages being incompatible with your project

I was trying to install the MathNet.Numerics package to my project (a class library), when I got this error:
The NuGet operation failed due to one or more packages being incompatible with your project. The '.NETPlatform,Version=v5.0' ('dotnet') project framework is deprecated. For more information about how to migrate your projects to a supported framework, please refer to themigration document (https://aka.ms/rugr4c). Would you like to continue with the project action(s) anyways?
This error also occured when I tried to update the Microsoft.NETCore.Portable.Compatibility package. Does anybody know what is causing this issue? I don't quite get what the error is saying even after some research, and I couldn't find anyone else with this issue. Thanks.
The nuget operation failed due to one or more packages being incompatible with your project
That because in the Visual Studio 2017 15.3:
You had two ways to target .NET Standard: one was via letting a PCL
target .NET Standard. The other was via the new .NET Standard
project type. NuGet team disabled the UI for letting a PCL target
.NET Standard because it never worked well. It sounds like we’ve
accidentally broken something else that affects existing projects.
However, you can use the .NET Standard project type, i.e. File |
New Project | .NET Standard | Class Library (.NET Standard) to target .NET Standard 1.x/2.x, which can still be
consumed from .NET Core 1.x/2.x.
Check the blog Announcing .NET Standard 2.0 for some details
Hope this helps.

How to Downgrade to .NET Core 1.0?

I am a beginner in .NET Core. I am learning Lynda's "Learn ASP.NET Core MVC The Basics" course. When I try to learn example code of Chapter 1, Video 5, this error appears:
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=808681
After going through several questions on Stack Overflow, I find that it is caused due to the inclusion of older .NET Core Version (1.0) in the exercise files. But the Visual Studio in my computer has Version 2.1.4. The folder "wwwroot" in the exercise might also cause the issue.
It seems that the only way I can fix this issue is by downgrading to Version 1.0. But how can I do it? Do I have to uninstall Visual Studio Code and install it with .NET Core V 1.0?
"Downgrade" is not a feature that is supported in Visual Studio.
Option 1
Find a tutorial that uses .NET Core 2.0. Microsoft has really good tutorials and documentation, depending on what you want to cover.
.NET Core 1.0 was basically a beta that Microsoft called 1.0. You gain nothing by learning .NET Core 1.0 at this point due to its limited amount of functionality (and usefulness) compared to .NET Core 2.0.
.NET Core 2.1 is soon to be released as well.
Option 2
Create a new project that targets .NET Core 1.0 in Visual Studio 2017 and put all of your .NET Core 1.0 code there.
Choose ASP.NET Core Web Application and name the project. Click OK.
On the next screen, change the project to target .NET Core 1.0 from the dropdown. Choose any other options from the tutorial. Click OK.
Option 3
Retarget your .NET Core 2.0 project to .NET Core 1.0.
From Solution Explorer, right click the project and choose Edit <projectName>.csproj.
Change the TargetFramework element from netcoreapp2.0 to netcoreapp1.0.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
...
</Project>
Fix any compile issues that making this change will likely create. Every project will have different issues depending on what is referenced by the project. There is no guide for this, you need to do research to find out what the problems are and fix them yourself. Google is your friend.
NOTE: None of this will likely fix the underlying cause to your error message, which is a completely different Stack Overflow question than what you are asking here.

How to test .NET Standard 2 library with either NUnit, xUnit or MSTest from either Rider or VS 2017?

I have a project where I use Azure Durable Functions, and they are available only on .NET Standard 2. So, it defines which class library can be used in testing projects. But, I cannot put together a library where either xUnit, NUnit or MSTest is used in unit/integration testing.
Adding NUnit to a project where .NET Standard 2 is class library fails with the following error:
INFO: Restoring packages for
C:\VSTS\github.com\netstandardXunitMsTestNunit\src\Netstandard2xUnitMsTestnUnit\nunit\nunit.csproj...
DEBUG: Restoring packages for .NETStandard,Version=v2.0... DEBUG:
Resolving conflicts for .NETStandard,Version=v2.0... ERROR: Cycle
detected. nunit -> NUnit (>= 3.9.0). DEBUG: Checking compatibility
of packages on .NETStandard,Version=v2.0. DEBUG: Checking
compatibility for nunit 1.0.0 with .NETStandard,Version=v2.0.
The error is the same for xUnit (just the error message talks about xUnit cycle).
Both error can be reproduced in Rider and Visual Studio 2017 Enterprise too. I tried it again after I cleaned nuget cache. The result is the same.
In case of MsTest, possible to add ms test libraries, but test discovery does not work neither Rider and nor Visual Studio.
Is it even possible unit test a .NET Standard 2 library?
Is there anything I can do beside waiting for these projects to pick up .NET Standard 2 stuff?
I created a small sample project, can be found here: https://github.com/SayusiAndo/netstandard2xunitresharper
There is no runtime for .NET Standard, so it will not execute your tests.
Your test assembly must target an executable platform, such as a version of .NET Framework or .NET Core.
<TargetFramework>net470</TargetFramework>
Or
<TargetFramework>netcoreapp2.0</TargetFramework>
See Running .NET Standard binaries on different frameworks for more details.
.NET Standard is a specification that each .NET Standard version(such as .NET Framework, .NET Core and Xamarin) defines the set of APIs that all .NET implementations must provide to conform to that version. You library has a value for TargetFramework of netstandard2.0 means you can reference the logic library not only from a .NET Core app, but also from an app built for .NET Framework or Xamarin.
However, You can’t build apps for it, only libraries. Here's the MSDN doc about .NET Standard.
So if you want to test the library, you need to specify the targets of which your library would support. And if you want to support multiple .NET version then you should test them all to make sure your library can run on these targets correctly. Here's the configuration of target framework in .csproj:
Single target:
<TargetFramework>net461</TargetFramework>
Multiple targets:
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
Create a new unit test project in the same solution that targets say .Net Framework 4.6.1 if your class library is to be used by an application that targets .Net Framework 4.6.1 so you test with the same combination of frameworks.
Add a reference to the class library project under references in the unit test project.
Add the xUnit and xUnit.runner.visualstudio nuget packages to the unit test project.
Rename the unit test class to something relevant, and replace the using MSTest directive with using XUnit.
Start writing and running tests.(build/re-build solution so it updates the tests list in the test explorer for each new test).
I have recently released my private unit test platform that does .NETStandard 2.0 just fine. Unless you have put a lot of time and effort into your tests you might want to have a look at Nuclear.Test.
Basically if you target your test project at .NETStandard it will execute these tests in a .NETFramework and .NETCore process to see if they both work correctly.
Unfortunately it requires .NETStandard 2.0 as a minimal version so far. Luckily that's what you are using.
This solution is neither NUnit nor xUnit nor MSTest but it will do exactly what you described.

Categories