我添加了 xunit 包来测试我的应用程序是否正常工作,但是当我尝试通过
dotnet test
运行我的代码时,出现错误:
点网测试
错误: 找不到应用程序依赖项清单 (testhost.deps.json) 中指定的程序集: 包:'Microsoft.TestPlatform.CommunicationUtilities',版本:'17.8.0-release-23523-03' 路径:'Microsoft.TestPlatform.CommunicationUtilities.dll'。
试运行已中断。
以前的项目需要安装 NuGET,所以我也这样做了。
我尝试将其放入 .csproj 中,但没有任何改变:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
我已经找到了这个问题的解决方案。 只需在终端中安装 xunit.runner 包即可:
dotnet add package xunit.runner.visualstudio
然后你就可以运行
dotnet test
。