在 YAML 文件中使用 dotnet restore 命令从本地 feed 恢复 NuGet 包时,可能会出现以下奇怪的行为:
为了解决这些问题,可以使用 nuget.config 文件来配置 NuGet 包源和恢复行为。可以在以下位置创建 nuget.config 文件,并将其添加到源代码控制中:
.\solution\
├───src\
│ ├───MyProject\
│ └───MyProject.Tests\
└───nuget.config
nuget.config 文件示例:
在 Pipeline 的 YAML 文件中,使用以下命令从本地 feed 恢复与项目匹配的所有 NuGet 包:
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: '**/*.csproj'
feedsToUse: 'config'
nugetConfigPath: './nuget.config'
如果需要恢复指定的 NuGet 包,可以在该命令中使用 --package 参数:
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: '**/*.csproj'
feedsToUse: 'config'
nugetConfigPath: './nuget.config'
arguments: '--package MyPackage1 --package MyPackage2'
上述代码会从 ./../../nuget-local
上一篇:AzureDevOpsPipeline执行MSBuild构建时不生成web目录,与本地命令不同。
下一篇:AzureDevOpsPipeline中使用SonarQube导致错误MSB6006:“csc.dll”退出代码为137。