是否可以对 dotnet 全局/本地工具使用通配符版本?

Kev*_*ith 5 .net .net-core dotnet-tool

我们使用正常方式dotnet-tools.json为我们的项目设置 dotnet 本地工具,但想知道是否有一种方法可以使用通配符版本作为版本号,就像您在 csprojs 中使用包引用所做的那样?

<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-rc.1.*" />
Run Code Online (Sandbox Code Playgroud)

我尝试将其更改dotnet-tools.json为以下内容:

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "dotnet-ef": {
      "version": "5.0.0-rc.1.*",
      "commands": [
        "dotnet-ef"
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但是运行却dotnet tool restore出现以下错误

Invalid manifest file. Path C:\dev\x\x.api\.config\dotnet-tools.json:
        In package dotnet-ef:
                Version 5.0.0-rc.1.* is invalid.
Run Code Online (Sandbox Code Playgroud)

lil*_*eng 1

找到代码中错误消息的来源,您可以看到版本解析是由NugetVersion.TryParse完成的,它只允许 semver 字符串。
所以不可能添加通配符。