运行 `dotnet test` 相当于纯 Mono

Run `dotnet test` equivalent with pure Mono

我正在尝试 F# 并有一个我可以 运行 dotnet test 的小项目,但我想在不安装 Microsoft 的任何非自由软件的情况下完成它。

使用 dotnet 的替代方法似乎都使用了相当复杂的命令,例如:

$ mono packages/xunit.runner.console.2.0.0/tools/xunit.console.exe build/test/CommandLine.Tests.dll

作为一个完全的新手,我对那些可能需要调整才能在我的情况下工作的提示为零。

我的 HelloWorld.fsproj 包含:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="HelloWorld.fs" />
    <Compile Include="HelloWorldTests.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
    <PackageReference Include="FsUnit.xUnit" Version="4.0.2" />
  </ItemGroup>

</Project>

Mono 和 .NET core 都有 MIT 许可证。现在没有理由不使用 .NET Core,特别是 .NET Core 5 旨在统一 .NET Core 和 Mono 的功能。

另外请注意,如果您没有使用 Visual Studio(商业许可),您的项目代码中会有一个不必要的行。

 <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />