I was following the new .NET Core 2.2 –> 3.0 upgrade document, but when I updated my unit test project files, I accidentally set the SDK to Microsoft.NET.Sdk.Web because that’s what my ASP.NET Core 3.0 web project was.
The unit tests still ran and worked… for the most part. One of them failed, so I tried to debug it and was left with this error message:
A fatal error has occurred and debugging needs to be terminated. The debugger was configured to use the Desktop CLR (.NET Framework) Managed debugger, but the target process loaded the CoreCLR (.NET Core) runtime. To debug this project, configure it to use the ‘Managed (CoreCLR)’ debugger.
I could not for the life of me find out how to configure the debugger on the project – all of the project settings in the .csproj file were the same as a different .csproj in a solution that I upgraded, and those tests are fully debuggable. Google didn’t help either, which is why I am writing this post including the full text of the error message, so hopefully I can help someone else.
Solution
A unit test project Sdk in the .csproj should be Microsoft.NET.Sdk.
Additionally, if you accidentally set it to Microsoft.NET.Sdk.Web, a Properties/launchSettings.json file will be created. This provides instructions to visual studio and dotnet as to how to run your web application, but, since its a unit test console application, it shouldn’t be launched as a web project. Delete this file, and things should work like you expect.
Andrew Hall
thank you , thank you , thank you , a thousand million thank-yous
Pants
Thanks for this!
Upgrading to VS 2019 16.6.2 has been one issue after the other. This was one of them.
Ronald Garlit
I have this same error with a brand new MSTESST Test Project in .NET Core 3.1.
But removing that file does not fix it in VS2019 Pro 16.7.7
Dependencies section has:
Framework: Microsoft.NETCore.App.Ref V3.1.0
Packages;
coverlet.collector v1.3.0
Microsoft.NET.Test.SDK v16.7.1
MSTest.TestAdapter V2.1.1
MSTest.TestFramework v2.1.2
Do I need to change any of those to something else?
I’m getting really gray on this one.
Thanks for any input you might provide.
Thanks Ron
Robert
Hey Ron,
I haven’t seen this error when creating a brand new test project in 3.1… I’ve been using xunit and not using the MSTest adapter/framework, so my guess would be to look into that?
Ronald Garlit
Thanks
We are standardized on MSTest here in old .NET FW.
I’ve submitted this to the Microsoft Developer Community.
https://developercommunity.visualstudio.com/content/problem/1239932/net-core-unit-testing-debugger-issue-a-fatal-error.html
I’ll repost here if I find out anything useful/a fix from them.
Thanks again for the reponse.
Ron
Ronald Garlit
Thanks
We are standardized on MSTest here in old .NET FW.
I’ve submitted this to the Microsoft Developer Community.
https://developercommunity.visualstudio.com/content/problem/1239932/net-core-unit-testing-debugger-issue-a-fatal-error.html
I’ll repost here if I find out anything useful/a fix from them.
Thanks again for the reponse.
Ron