I'm migrating from .NET 5 and all tests are working, and finishing succesfully, until I update all .csproj files to .NET 6.0 like this:
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
Afterwards all integration and unit tests show as inconclusive in Rider with the following error:
Test not run
Last runner error: Test runner agent exited unexpectedly Process /usr/share/dotnet/dotnet:138437 exited with code '140': Error: An assembly specified in the application dependencies manifest (Logging.UnitTests.deps.json) was not found: package: 'Autofac', version: '6.4.0' path: 'lib/net6.0/Autofac.dll'
--- EXCEPTION #1/3 [UnknownExitCodeException]
Message = “
Process /usr/share/dotnet/dotnet:138437 exited with code '140':
Error:
An assembly specified in the application dependencies manifest (Logging.UnitTests.deps.json) was not found:
package: 'Autofac', version: '6.4.0'
path: 'lib/net6.0/Autofac.dll'
”
I have tried updating all nuget packages, including autofac, to the latest version, tried all possible combinations with Autofac, but the error still remains. I'm on Arch linux and have all the correct dotnet sdks and runtimes.
dotnet --list-sdks
5.0.407 [/usr/share/dotnet/sdk]
6.0.102 [/usr/share/dotnet/sdk]
6.0.301 [/usr/share/dotnet/sdk]
dotnet --list-runtimes
Microsoft.AspNetCore.App 5.0.16 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.16 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
The application runs normally in both Run and Debug mode, it's just that all tests have stopped working. This also happens in the GitHub pipeline, any ideas?
Thank you very much in advance!
So after many hours finding a fix I tried the following:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
TL;DR, add the following to every test project you have:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>