_From @couven92 on February 24, 2017 10:45_
Ref.: https://github.com/Microsoft/VSProjectSystem/issues/195
Originally issued in wrong repository
Here's my CSPROJ:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>
</PropertyGroup>
<PropertyGroup Label="BasePath">
<BaseOutputPath>$(SolutionDir)bin\</BaseOutputPath>
<BaseIntermediateOutputPath>$(SolutionDir)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170222-09" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
</Project>
Note the (as of writing this issue) the newest versions for the Test SDK and XUnit packages. I'm using the newest RC for Visual Studio 2017 (Version 15.0.0-RC4+26206.0)
Also note that I'm setting the BaseOutputPath and BaseIntermediateOutputPath to values different from their defaults.
Running test cases from the Test Explorer view in Visual Studio works fine. However, when I choose to debug one or more tests, Visual Studio goes over into debugging mode, and immediately displays a crtical error message window:
A fatal error has occurred and debugging needs to be terminated. For more details, please see the Microsoft Help and Support web site. HRESULT=0x8000ffff. ErrorCode=0x0.
_Copied from original issue: dotnet/roslyn-project-system#1620_
_From @dmenoud on February 27, 2017 15:27_
I have the same problem.
Running its ok, but debugging crash.
Microsoft Visual Studio Professional 2017 RC
Version 15.0.26206.0
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>BtimeServer.Engine.Tests</AssemblyName>
<PackageId>BtimeServer.Engine.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\BtimeServer.Common\BtimeServer.Common.csproj" />
<ProjectReference Include="..\..\src\BtimeServer.Data\BtimeServer.Data.csproj" />
<ProjectReference Include="..\..\src\BtimeServer.Engine\BtimeServer.Engine.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
</ItemGroup>
</Project>

By any chance is there a launchSettings.json for this project? We've seen this issue earlier when launchSettings.json was pointing to an incorrect path.
Hmm... I wanted to give you a launchSettings.json (because I hvae had problems with that one before as well), but I discovered that I don't have any launchSettings.json for the test project.
Had the same problem, for me removing launchSettings.json fixed it!
Would be nice if my problem could be solved as simple as that. But I have no launchSettings.json that I could delete! And it still does not work at my end...
Have you got any other test adapter installed? I had the same problem, for me disabling the NUnit adapter fixed it.
I had the same error, no launchSettings.json file present and no other adapters. I'm not sure exactly what fixed the problem but I did a couple of things. I closed VS 2017, ran the test on the command line (dotnet test) then reopened my project in VS2017. During the launch I got a "Inconsistent Line Endings" prompt for my test .cs file. I confirmed to make all line endings CR LF. Now things work!
In my case, this is probably related to: https://github.com/dotnet/sdk/issues/1018
As stated in https://github.com/dotnet/sdk/issues/1018#issuecomment-289134060 the following comment and discussion https://github.com/Microsoft/msbuild/issues/1603#issuecomment-283104367 gives a possible solution.
I had the same problem. Using the solution outlined by bryanrcarlson solved the issue.
Thanks!
I had the same problem. Using the solution outlined by @bryanrcarlson solved the issue.
Thanks!
sorry @andrey-yemelyanov , I copied your comment.
I had the same problem with xUnit and solved this problem changing project type from Library to Console Application:
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp1.1|AnyCPU'">
<OutputType>exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
<AssemblyName>MyProject.UnitTests</AssemblyName>
<ApplicationIcon />
<OutputTypeEx>exe</OutputTypeEx>
<StartupObject />
</PropertyGroup>
My final csproj: https://gist.github.com/ircnelson/9cbddb681d520d7f581dbfc99709a9e1
I also had the same problem. Using VS 2017 with .Net Core 1.1.1, Microsoft.NET.Test.Sdk(15.0.0), xunit(2.2.0), xunit.runner.visualstudio(2.2.0).
The solution by @bryanrcarlson solved the issue. Thanks! I did also copy the comment from @andrey-yemelyanov, Thanks!
I am having the exact same problem. @bryanrcarlson's solution does not help. There is a launchsettings.json in the target assembly, but not in the unit test assembly.
The solution by @ircnelson worked for me.
I had the same problem. No launchsettings.json. Using the solution outlined by @bryanrcarlson solved the issue.
Thanks!
Similar issue being hit for Nunit here
I hit this error while debugging an MSTest test case in VS 2017 (version 15.3.5)
The solution from @bryanrcarlson worked (albeit VS did not prompt about line endings on load, so I manually saved the file and selected CR LF line endings; see https://stackoverflow.com/questions/43323941/inconsistent-line-endings-visual-studio-community-2017)
I cannot repro this on 15.4. I tried the project from here. Can anyone confirm please?
Just had this problem with 15.4.1. Solved by deleting launchsettings.json that someone had added to a library project.
I keep getting this every day, I end up having to clear everything down including temp directory then it lets me get back to work. I'm on VS 15.4.1
Thanks for the responses.
@Jetski5822 : Do you happen to have repro steps/a project that you could share? That would greatly help.
This is being tracked external to this repo here:
https://developercommunity.visualstudio.com/content/problem/145944/debugging-xunit-test-cases-fails-critically.html
@AbhitejJohn Clean solution worked for me
Edit: Rereading your comment, you are looking for a reproduction and not a workaround. Sadly, i can't reproduce the issue.
I'm having this problem with VS 15.5.4
If I load solution on startup, then ask to "debug" a unit test, I get the fatal error message.
If load solution on startup, open the "Manage NuGet Packages for Solution" window, then ask to "debug" a unit test, it works! Stumbled upon this workaround for me accidentally...still can't fathom why
Had the same isssue with VS 2017 15.5.6 and .NET Core 2.0 using XUnit.
Had no launchsettings.json, and the solution by @bryanrcarlson did not help.
Managed to fix it by disabling the nUnit test adpators from Tools->Extensions and Updates
No dice on @bryanrcarlson and no launchsettings.json. Fixed by updating .netcore packages to latest (2.0.5). Debug tests now working. ???
I've run in to the same problem and none of the fixes listed here helped. I started a brand new asp.net core web app and hit the same roadblock of not being able to debug tests. The tests are embedded in the main project file and that appears to be causing the problem. If I create a regular unit test project in the same solution then debugging is fine. Here is a repo repo: https://github.com/svickers/Debug_no_worky
Clean Solution worked for me as well.
Add one more for deleting launchsettings.json fixed it. If someone is unsure where it is, it's under the Properties folder.
Still failing with Visual Studio 15.8.6 and xunit 2.4.0. Tried all of the above workarounds to no avail. Running of tests works but debugging fails with

Failing with VS 15.9.5, NUnit3TestAdapter 3.12, Microsoft.NET.Test.Sdk 15.9 when debugging tests targeting .NET Framework 4.52 . But it works when debugging the same test targeting .NET Core App 2.0/2.2.
@CalArabshahi, @ognjenkurtic : If you haven't already, could you delete the .vs folder for your solution and try this out please(@ognjenkurtic you might want to update to the latest as well)? If that doesn't work, would you be able to file an issue in developercommunity and paste a link here please? This specific issue would get more traction there.
Most helpful comment
Had the same problem, for me removing
launchSettings.jsonfixed it!