【问题标题】:Locally installing dotnet tool uses old command name本地安装 dotnet 工具使用旧命令名
【发布时间】:2020-06-17 20:36:00
【问题描述】:

我已经按照 create a dotnet toolinstall it locally 的教程进行操作。满意后,我尝试将命令的名称从botsay 更改为something-else。不幸的是,它总是使用命令名称botsay 安装。即使我运行dotnet tool uninstall,删除项目并重新开始,它仍然使用教程中的名称。我可以更改它的唯一方法是将项目名称更改为其他名称。为什么它使用旧的命令名称,我该如何更改它?

目录结构为:

sources
--My.Project.Name
----nupkg
------My.Project.Name.1.0.0.nupkg
--.config
----dotnet-tools.json

我的 csproj 是:

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

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.1</TargetFramework>

        <PackAsTool>true</PackAsTool>
        <ToolCommandName>something-else</ToolCommandName>
        <PackageOutputPath>./nupkg</PackageOutputPath>
    </PropertyGroup>

</Project>

而 dotnet-tools.json 是:

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "my-project-name": {
      "version": "1.0.0",
      "commands": [
        "botsay" <--- I want this to be "something-else"
      ]
    }
  }
}

【问题讨论】:

    标签: c# .net-core csproj dotnet-tool


    【解决方案1】:

    好的,找到答案了。该软件包是从缓存中安装的。我曾尝试将--no-cache 参数提供给dotnet tool install,但这并没有什么不同。解决办法是:

    1. 运行nuget locals all -List
    2. 在这些位置之一找到缓存的包
    3. 删除它

    【讨论】:

      猜你喜欢
      • 2021-07-20
      • 1970-01-01
      • 2019-05-20
      • 2019-01-29
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 2019-03-02
      • 1970-01-01
      相关资源
      最近更新 更多