在 azure 代理中运行 nunit 测试时找不到 testhost.deps.json 文件

Den*_* S. 11 .net azure azure-devops

我正在 azure devops 代理上运行一些 API 测试并收到此警告错误消息

  2021-05-21T13:42:29.0650201Z ##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process exited with error: Cannot use file stream for [C:\a\r1\a\_Automation-Build\drop\TestAutomation.UI.PageObject\bin\Debug\netcoreapp3.1\testhost.deps.json]: No such file or directory
2021-05-21T13:42:29.0661479Z ##[debug]Processed: ##vso[task.logissue type=error;]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process exited with error: Cannot use file stream for [C:\a\r1\a\_Automation-Build\drop\TestAutomation.UI.PageObject\bin\Debug\netcoreapp3.1\testhost.deps.json]: No such file or directory
2021-05-21T13:42:29.0663114Z A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'.
2021-05-21T13:42:29.0663661Z Failed to run as a self-contained app.
2021-05-21T13:42:29.0664305Z   - The application was run as a self-contained app because 'C:\a\r1\a\_Automation-Build\drop\TestAutomation.UI.PageObject\bin\Debug\netcoreapp3.1\testhost.runtimeconfig.json' was not found.
2021-05-21T13:42:29.0665393Z   - If this should be a framework-dependent app, add the 'C:\a\r1\a\_Automation-Build\drop\TestAutomation.UI.PageObject\bin\Debug\netcoreapp3.1\testhost.runtimeconfig.json' file and specify the appropriate framework.
2021-05-21T13:42:29.0666319Z . Please check the diagnostic logs for more information.
2021-05-21T13:42:29.0667169Z    at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(Boolean testHostExited)
2021-05-21T13:42:29.0668081Z    at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
2021-05-21T13:42:29.0668810Z    at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
Run Code Online (Sandbox Code Playgroud)

我还浏览了那篇文章https://www.gitmemory.com/issue/microsoft/vstest/2218/540508574,我不确定如何使用选项应用测试文件test plan选择test assemblies在此输入图像描述 在此输入图像描述

Kev*_*SFT 6

遇到致命错误。在“C:\Program Files\dotnet”中找不到执行应用程序所需的库“hostpolicy.dll”。

根据错误信息,您可以参考这个Github Ticket

您可以尝试以下方法:

  1. 更改 VSTest 任务中的测试文件路径(从**\*test*.dll**\*test.dll)。

  2. 删除一个测试装配体对另一测试装配体的引用

  3. 将 Microsoft.NET.Test.SDK 更新到 16.6.1