I am not sure if this problem is xunit or vstest (or dotnet test) related, but I have trouble running a simple xunit test project using dotnet test on Windows when a test project targets both .NET 4.8 and .NET 8.0.
Change the project to target both .net8.0 and net48:<TargetFrameworks>net8.0;net48</TargetFrameworks>.
Remove c# features not supported by .net 4.8: ImplicitUsings and GlobalUsings
Change the Class1.cs for this:
namespace ClassLib1
{
public class Class1
{
[Xunit.Fact]
public void Test1() { }
}
}
Run dotnet build and dotnet test
The tests are run against .NET 4.8 and fail against .NET 8.0
The console output is:
Determining projects to restore...
All projects are up-to-date for restore.
ClassLib1 -> C:\code\github\vstest-lab\ClassLib1\bin\Debug\net8.0\ClassLib1.dll
ClassLib1 -> C:\code\github\vstest-lab\ClassLib1\bin\Debug\net48\ClassLib1.dll
Test run for C:\code\github\vstest-lab\ClassLib1\bin\Debug\net8.0\ClassLib1.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process for source(s) 'C:\code\github\vstest-lab\ClassLib1\bin\Debug\net8.0\ClassLib1.dll' exited with error: Error:
An assembly specified in the application dependencies manifest (ClassLib1.deps.json) was not found:
package: 'xunit.abstractions', version: '2.0.3'
path: 'lib/netstandard2.0/xunit.abstractions.dll'
. Please check the diagnostic logs for more information.
Test Run Aborted.
Test run for C:\code\github\vstest-lab\ClassLib1\bin\Debug\net48\ClassLib1.dll (.NETFramework,Version=v4.8)
Microsoft (R) Test Execution Command Line Tool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: - ClassLib1.dll (net48)
The interesting error is: An assembly specified in the application dependencies manifest (ClassLib1.deps.json) was not found: package: 'xunit.abstractions', version: '2.0.3' path: 'lib/netstandard2.0/xunit.abstractions.dll'.
Running with -f net48 works. Running with -f net8.0 gives the same error.
Obviously, Adding the xunit.abstractions package does not fix the problem.
When running with the --diag:log.txt I get the following output:
Hi,
I am not sure if this problem is xunit or vstest (or dotnet test) related, but I have trouble running a simple xunit test project using
dotnet test
on Windows when a test project targets both .NET 4.8 and .NET 8.0.Steps to reproduce (I also created a simple repo here: https://github.com/tbolon/vstest-lab)
dotnet new classlib
dotnet add package xunit
&dotnet add package xunit.runner.visualstudio
<TargetFrameworks>net8.0;net48</TargetFrameworks>
.dotnet build
anddotnet test
The console output is:
The interesting error is:
An assembly specified in the application dependencies manifest (ClassLib1.deps.json) was not found: package: 'xunit.abstractions', version: '2.0.3' path: 'lib/netstandard2.0/xunit.abstractions.dll'
.Running with
-f net48
works. Running with-f net8.0
gives the same error.Obviously, Adding the xunit.abstractions package does not fix the problem.
When running with the
--diag:log.txt
I get the following output: