Dot-Net-Core

如何從命令行執行“dotnet xunit PathToLibrary.dll”(在持續集成中)

  • September 18, 2018

當我在項目所在的文件夾中時,我可以“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 是一個基於項目的 CLI 工具

使用這些工具需要您為<DotNetCliToolReference>要使用的每個工具在項目文件中添加一個元素。在<DotNetCliToolReference>元素內部,您引用該工具所在的包並指定您需要的版本。執行 dotnet restore 後,將恢復該工具及其依賴項。

因此,請檢查您的 .csproj 是否包含

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

然後做

dotnet restore

引用自:https://stackoverflow.com/questions/46954039