如何在Azure Pipelines上为Azure Artifact feed运行`dotnet list package --deprecated`

问题描述

我正在尝试为使用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

然后:

错误:响应状态代码未指示成功:401(未授权)。

我尝试通过以下方式显式添加源:

  - 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的权限:

enter image description here

我也在GitHub dotnet list package --outdated` doesn't work with sources that need auth #7605上找到了该主题,尽管现在已关闭,但我在此看不到太多帮助。

当我使用--interactive标志在本地运行时,系统会不断提示登录

enter image description here

但是,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并仔细阅读,但我仍在尝试解决此问题。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...