Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Coould not run xunit tests for two frameworks in one project

See original GitHub issue

Steps to reproduce

I have this csproj

<Project ToolsVersion="15.0" xmlns="">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
    <Compile Include="**\*.cs" />
    <PackageReference Include="Microsoft.NET.Sdk">
    <PackageReference Include="Microsoft.NET.Test.Sdk">
    <PackageReference Include="xunit">
    <PackageReference Include="xunit.runner.visualstudio">
  <ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
    <Reference Include="System" />
    <Reference Include="Microsoft.CSharp" />
  <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
    <PackageReference Include="Microsoft.NETCore.App">
    <PackageReference Include="Microsoft.NETCore.Portable.Compatibility">
    <PackageReference Include="Microsoft.TestPlatform.TestHost">
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Expected behavior

dotnet test --framework net46 dotnet test --framework netcoreapp1.0

Actual behavior

dotnet test --framework net46 - works fine dotnet test --framework netcoreapp1.0 - does not work. I got an error

Starting test execution, please wait...
Error: Could not find testhost.dll for source 'C:\Projects\ProjectName\bin\Debug\netcoreapp1.0\ProjectName.dll'. Make sure test project has a nuget reference of package "microsoft.testplatform.testhost".

Environment data

.NET Command Line Tools (1.0.0-preview4-004123)

Product Information: Version: 1.0.0-preview4-004123 Commit SHA-1 hash: 3a3ab7e0b0

Runtime Environment: OS Name: Windows OS Version: 10.0.14393 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\1.0.0-preview4-004123

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

alexvaluyskiycommented, Nov 26, 2016

I’ve added these two lines and it started working

coditocommented, Jan 9, 2017

As of 87e9815a25a29fbfa8b87b5757bd44075ef6df4a, Microsoft.NET.Test.Sdk can handle OutputType mismatch between netcoreapp and net4x targets. There is no need to specify OutputType in the test project csproj.

Please try build/test with latest dotnet-cli dev build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Coould not run xunit tests for two frameworks in one project
Steps to reproduce. I have this csproj · Expected behavior. dotnet test --framework net46 · Actual behavior. dotnet test --framework net46 - works ......
Read more >
How to properly unit test a .NET project with multiple target ...
First, test projects can multi-target as well by making use of the <TargetFrameworks> property just like you used for the library.
Read more >
Running Tests in Parallel
Parallelism in Test Frameworks​​ Tests written in version 1 cannot be run in parallel against each other in the same assembly, though...
Read more >
XUnit tests do not run in solution
The problem is specifically with XUnit test projects, because NUnit and MsTest projects run tests normally. All the packages in XUnit project ......
Read more >
How To Resolve Issue Of Test Project Not Running The ...
Two of my test projects didn't run the test cases, it was about to start and took some time to run the test...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found