更新时间:2023-02-08 23:23:32
1.好像您正在尝试将凭据添加到 Nuget.config
文件中,因此不推荐,因为:
1.Looks like you're trying to add the credentials into Nuget.config
file, this is not recommended because:
我们强烈建议您不要将PAT签入源代码管理中.有权访问您的PAT的任何人都可以访问您的Azure DevOps服务.
尽管不建议这样做,但它应该可以工作.对我来说,我使用以下命令:
Though it's not recommended, it should work. For me I use command like:
dotnet nuget push --source "myfeed" --api-key az Test.1.0.0.nupkg
和Nuget.config:
And the Nuget.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="myfeed" value="https://pkgs.dev.azure.com/myacct/myproject/_packaging/myfeed/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<myfeed>
<add key="Username" value="lancel" />
<add key="ClearTextPassword" value="YourPat, instead of the APIkey" />
</myfeed>
</packageSourceCredentials>
</configuration>
It means you'll need to create PAT which is scoped to the organization(s) you want to access with following permissions: Packaging (read), Packaging (read and write), or Packaging (read, write, and manage).
然后应为< add key ="ClearTextPassword"值=%PAT%"/>
.
2.And another direction is to use Azure Artifacts Credential Provider in non-interactive scenarios.
运行帮助程序脚本以自动安装它,并设置一个 VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
变量.该变量的值应为:
Run the helper script to install it automatically and set a VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
variable. The value of this variable should be:
{"endpointCredentials": [{"endpoint":"https://pkgs.dev.azure.com/myacct/myproject/_packaging/myfeed/nuget/v3/index.json", "password":"PAT"}]}