所有测试都没有定论,而没有找到应用程序依赖项中指定的组件。迁移到.NET 6时错误

发布于 2025-02-10 09:46:54 字数 1657 浏览 2 评论 0原文

我正在从.NET 5迁移,所有测试都在工作,并成功完成,直到我将所有.CSPROJ文件更新为.NET 6.0这样:

  <PropertyGroup>
      <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

之后所有集成和单元测试在骑手中显示为不确定的,并带有以下错误:

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'
”

我有尝试将所有Nuget软件包(包括AUTOFAC)更新为最新版本,尝试与AutoFac进行所有可能的组合,但仍然存在错误。我在Arch Linux上,拥有所有正确的dotnet SDK和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]

该应用程序在运行和调试模式下正常运行,只是所有测试都停止工作。这也发生在GitHub管道中,有什么想法吗?

非常感谢您!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

刘备忘录 2025-02-17 09:46:54

因此,经过数小时的修复,我尝试了以下操作:

  • 创建一个新的.NET 6测试项目,
  • 看看没有依赖关系的小测试是否有效,并且确实有效。
  • 查看自动添加到该测试项目的Nuget软件包参考
  • ,以查看未能失败的测试项目中的Nuget软件包REPRESS
  • ,意识到只有隐式引用,请记住它在 ^&amp;%$中的 @$% ^ me如何过去,
  • 在每个测试项目中,直接引用“ Microsoft.net.test.sdk”和“ Xunit”:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
  • 见证所有测试如何再次正确运行。

tl; dr,将以下内容添加到您拥有的每个测试项目中:

  <ItemGroup>
      <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
      <PackageReference Include="xunit" Version="2.4.1" />
  </ItemGroup>

So after many hours finding a fix I tried the following:

  • Create a new .NET 6 test project
  • See if a small test without dependencies works, and it did work.
  • Look at the NuGet package references that were automatically added to that test project
  • Look at the NuGet package refences in the tests projects that were failing
  • Realize some were only implicitly referenced, remember how this has @$%^ me in the ^&%$ in the past
  • Directly reference "Microsoft.NET.Test.Sdk" and "xunit" in every test project like this:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
  • Witness how all tests are running correctly again.

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文