【发布时间】:2020-02-04 13:20:58
【问题描述】:
今天,我试图在 NuGet 还原阶段修复来自多个源的构建管道,但无法找到要使用的正确设置。
我有三个不同来源的包,
- 公共 Nuget
- 私有 Azure DevOps 工件。
【问题讨论】:
标签: .net asp.net-core azure-devops yaml build-pipeline
今天,我试图在 NuGet 还原阶段修复来自多个源的构建管道,但无法找到要使用的正确设置。
我有三个不同来源的包,
【问题讨论】:
标签: .net asp.net-core azure-devops yaml build-pipeline
如果你有一个私人仓库要添加到你的 NuGet 恢复中,那么它很容易,
你的 YAML 应该是这样的
要添加第二个任务,请将鼠标焦点放在- task: NuGetToolInstaller@1 的下一行,然后在右侧窗格中搜索 NuGet 并选择要添加的 Articat
如果您有多个私有源要恢复,最好的方法是从nuget.config 文件恢复包。
首先,在源代码管理的根目录中添加一个 nuget.config 文件。
如下添加您的 nuget 包源
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="AAA" value="https://pkgs.dev.azure.com/XXX/Prototypes/_packaging/YYY/nuget/v3/index.json" />
<add key="BBB" value="https://pkgs.dev.azure.com/XX/IdentityServer/_packaging/YYY/nuget/v3/index.json" />
</packageSources>
</configuration>
现在在您的 YAML 上添加以下代码。
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: '**\*.sln'
feedsToUse: config
nugetConfigPath: 'nuget.config'
您的构建管道应该开始工作了。评论如果有任何错误。
【讨论】: