我刚在yml
管道中碰到了这个问题,花了一个小时阅读文档。所以我想在这里写一篇答案,因为自那时以来情况发生了很大变化。
解决方法仍然是使用NuGet.config
文件。但这还不够。您还需要正确配置NuGetCommand@2
或DotNetCoreCLI@2
,以便它使用.config
文件。这是您配置它的方式:
- task: NuGetCommand@2
displayName: 'Restoring NuGet packages'
inputs:
restoreSolution: '**/*.sln'
feedsToUse: config
nugetConfigPath: NuGet.Config
- task: DotNetCoreCLI@2
displayName: Restoring NuGet packages
inputs:
command: restore
projects: '**/*.csproj'
feedsToUse: config
nugetConfigPath: NuGet.Config # Relative to root of the repository
feedsToUse
属性的值为config
,否则管道不会使用你的.config
文件。或者
目前,NuGet还只能在Feed(s) I select here选项中选择一个源。
我为这个功能创建了一个问题Enable to select multiple feeds in NuGet restore task Feed(s) I select here,你可以跟进。
目前的解决方法是使用包含所需源的NuGet.config
文件。或者将需要使用的VSTS源添加为终结点,然后从Credentials for feeds outside this account/collection选项中选择这些源。