dotnet 工具安装--global dotnet-sonarscanner 错误

Cha*_*fer 5 .net c# sonarqube

只是尝试在本地安装没有 docker 镜像的 Sonarqube:

-- dotnet tool install --global dotnet-sonarscanner C:\Program Files\dotnet\sdk\6.0.200\NuGet.targets(130,5): 错误:无法加载源https://pkgs 的服务索引。 dev.azure.com/tPointAgileOrg/tPoint/_packaging/tPoint/nuget/v3/index.json。[C:\Users\Anri_Kezeroti\AppData\Local\Temp\utymnwsa.3vd\restore.csproj] C:\Program Files\dotnet\sdk\6.0.200\NuGet.targets(130,5):错误:响应状态代码不表示成功:401(未经授权)。[C:\Users\Anri_Kezeroti\AppData\Local\Temp\utymnwsa.3vd\restore.csproj]

工具包无法恢复。工具“dotnet-sonarscanner”安装失败。此故障可能是由以下原因引起的:

  • 您正在尝试安装预览版本,但未使用 --version 选项指定版本。
  • 找到了同名的包,但它不是 .NET 工具。
  • 无法访问所需的 NuGet 源,可能是由于 Internet 连接问题。
  • 您输错了该工具的名称。

有关更多原因(包括包命名强制),请访问https://aka.ms/failure-installing-tool

Him*_*ere 10

我在使用 v.5.7.2 时遇到了同样的问题。GitHub 上关于该主题的讨论仍在进行中。似乎在调用时dotnet install它也会隐式调用dotnet restore,这将使用您的Nuget.config. 当该文件中存在需要身份验证的私人源时,dotnet install将会失败,而不是仅使用下一个可用的源。因此,我们可以使用以下命令添加官方 nuget-feed 并忽略任何其他内容:

dotnet tool install --global dotnet-sonarscanner --add-source 'https://api.nuget.org/v3/index.json' --ignore-failed-sources
Run Code Online (Sandbox Code Playgroud)

这仍然会发出警告,因为无法访问私人提要。不过,它将进一步处理,您可以使用该工具。


Cha*_*fer 2

dotnet 工具安装 --global dotnet-sonarscanner --version 5.5.3

指定版本为我解决了问题。