问题描述
我正在尝试为使用Azure Artifact Feed中的程序包的项目运行dotnet list package --deprecated
。
我将其包装在DotNetCoreCLI
任务中:
- task: DotNetCoreCLI@2
displayName: 'List deprecated packages'
continueOnError: true
inputs:
command: custom
custom: list
arguments: 'package --deprecated'
我在nuget.config
文件中配置了源,当我使用dotnet restore
时,这很好用。但是,当我运行list package
时,我有:
The following sources were used:
https://api.nuget.org/v3/index.json
https://pkgs.dev.azure.com/...../nuget/v3/index.json
https://pkgs.dev.azure.com/......./nuget/v3/index.json
然后:
我尝试通过以下方式显式添加源:
- script: |
nuget sources add -name "Source1" -source https://pkgs.dev.azure.com/...../nuget/v3/index.json -username anything -password %sYstem_ACCEsstOKEN%
nuget sources add -name "Source2" -source https://pkgs.dev.azure.com/...../nuget/v3/index.json -username anything -password %sYstem_ACCEsstOKEN%
enabled: false
env:
SYstem_ACCEsstOKEN: $(System.Accesstoken)
displayName: Add NuGet source
但这失败了,因为:
The source specified has already been added to the list of available package sources. Provide a unique source.
The source specified has already been added to the list of available package sources. Provide a unique source.
我还修改了对Allow project-scoped builds
的权限:
我也在GitHub dotnet list package --outdated` doesn't work with sources that need auth #7605上找到了该主题,尽管现在已关闭,但我在此看不到太多帮助。
当我使用--interactive
标志在本地运行时,系统会不断提示我登录:
但是,dotnet restore
有效。我尝试了所有想到的方法,但仍然没有任何进展。它在本地和Azure管道上均不起作用。
您知道我在做什么错吗?
解决方法
我找到了解决方法。当我删除nuget.config
并显式添加源时,它成功了。
- script: |
del nuget.config
nuget sources add -name "Source1" -source https://pkgs.dev.azure.com/...../nuget/v3/index.json -username anything -password %SYSTEM_ACCESSTOKEN%
nuget sources add -name "Source2" -source https://pkgs.dev.azure.com/....../nuget/v3/index.json -username anything -password %SYSTEM_ACCESSTOKEN%
enabled: true
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
displayName: Add NuGet source
但是,我想知道是否还有另一种方法,因为这对我来说很奇怪。
正如 Jonathan Myers 所建议的那样,我使用了- task: NuGetAuthenticate@0
,它几乎可以正常工作。几乎是因为在分析第一个项目时得到了:
error: Problem starting the plugin 'C:\Users\VssAdministrator\.nuget\plugins\netcore\CredentialProvider.Microsoft\CredentialProvider.Microsoft.dll'. Plugin 'CredentialProvider.Microsoft' failed within 5.068 seconds with exit code -1.
error: Response status code does not indicate success: 401 (Unauthorized).
我找到了这个topic on Developer Community并仔细阅读,但我仍在尝试解决此问题。