如何从命令行 运行 "dotnet xunit PathToLibrary.dll"(在持续集成中)

How to run "dotnet xunit PathToLibrary.dll" from command line (in Continous Integration)

当我在项目所在的文件夹中时,我可以 "dotnet xunit"。

如何从命令行执行此操作,我想将已编译的 dll 作为参数传递。

dotnet xunit PathToLibrary.dll

我收到一个错误:

No executable found matching command "dotnet-xunit"

我已将 "xunit.execution.desktop.dll"(从 nuget xunit.core.2.3.0 获取)复制到当前文件夹,但这没有帮助。

dotnet-xunit 是一个 per-project CLI tool

Consuming these tools requires you to add a <DotNetCliToolReference> element to your project file for each tool you want to use. Inside the <DotNetCliToolReference> element, you reference the package in which the tool resides and specify the version you need. After running dotnet restore, the tool and its dependencies are restored.

因此请检查您的 .csproj 是否包含

<ItemGroup>
   <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0" />
</ItemGroup>

然后

dotnet restore

这个答案不是对 OP 的直接回答,但对 dotnet xunit

的用户来说是必需的

dotnet xunit 从 xunit 2.4 开始移除 Ref: Release Notes 2.4

发行说明摘录:

Unfortunately, this release also removes the dotnet xunit runner, as the stability of the runner was never perfect, and it suffered from many assembly-loading related issues. Users from .NET Core can continue to use VSTest (either inside Visual Studio, or via dotnet test).

因此,对于 xunit 框架测试,请使用 command

   dotnet test