vstest: Debugging XUnit test cases fails critically

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 32 (6 by maintainers)

Most upvoted comments

Had the same problem, for me removing launchSettings.json 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!

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.

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

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 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 had the same problem. Using the solution outlined by @bryanrcarlson solved the issue. Thanks! sorry @andrey-yemelyanov , I copied your comment.