将 AWS CodeArtifact CredentialProvider 与 .Net Core 结合使用 - 无法执行,因为找不到指定的命令或文件

问题描述

上周,我按照 this AWS tutorial 设置了我的 dotnet CLI,以将 AWS Code Artifact 与凭证提供程序结合使用。这可以通过 3 个命令完成:

  1. dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider
  2. dotnet codeartifact-creds install
  3. dotnet codeartifact-creds configure set profile profile_name

这一切都按预期进行,我能够从 dotnet CLI 将包发布到 AWS CodeArtifact。

但是今天,当我尝试使用 codeartifact-creds 命令时,我收到一个错误提示 dotnet 不知道该命令:

Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program,but dotnet-codeartifact-creds does not exist.
  * You intended to run a global tool,but a dotnet-prefixed executable with this name Could not be found on the PATH.

任何有关解决此问题并能够使用该工具的帮助都将受到赞赏。


我尝试过的:

  • 重新启动我的机器
  • 通过 CLI dotnet tool uninstall AWS.CodeArtifact.NuGet.CredentialProvider 删除工具,然后使用上面的 3 命令重新安装
  • 通过从 %home%/.dotnet/tools删除然后重新安装来手动删除工具

值得一提:

  • 我在 Windows 10 上的 WSL2 环境中运行 Debian
  • 自上次工作 (AFAIK) 以来唯一改变的是我重新启动了我的机器,没有别的。
  • 我安装了 dotnet core 3.1 和 5 SDK

解决方法

问题是 dotnet tools 文件夹的路径在重新启动后不再包含在我的 $PATH 变量中。

更新 $PATH 变量以包含 dotnet 工具文件夹 (%home%/.dotnet/tools) 解决了该问题。