[英]NuGet package restore in Azure DevOps build pipeline
This is a follow-up to a question I had yesterday: NuGet package restore in builds and Visual Studio这是我昨天遇到的一个问题的后续: NuGet package restore in builds and Visual Studio
I have since removed the ".nuget" solution folder from my VS2013 solution, but the "Visual Studio build" task in my build pipeline now fails, with an error for each project:我已经从我的 VS2013 解决方案中删除了“.nuget”解决方案文件夹,但是我的构建管道中的“Visual Studio 构建”任务现在失败了,每个项目都有一个错误:
[error]xxxxx.csproj(214,5): Error : This project references NuGet package(s) that are missing on this computer.
[错误]xxxxx.csproj(214,5):错误:此项目引用了此计算机上缺少的 NuGet 包。 Enable NuGet Package Restore to download them.
启用 NuGet 包还原以下载它们。 For more information, see http://go.microsoft.com/fwlink/?LinkID=322105 .
有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=322105 。 The missing file is c:\\Temp\\VSTS Agent_work\\10\\s\\xxxxx\\.nuget\\NuGet.targets.
丢失的文件是 c:\\Temp\\VSTS Agent_work\\10\\s\\xxxxx\\.nuget\\NuGet.targets。
I've tried checking the "Restore NuGet packages" option in the VS build task, but it makes no difference.我试过检查 VS 构建任务中的“还原 NuGet 包”选项,但没有区别。 The checkbox says this option is deprecated, and to use the "Nuget tool installer" task - I've tried this too but it still didn't help.
该复选框表示此选项已弃用,要使用“Nuget 工具安装程序”任务 - 我也尝试过此操作,但仍然没有帮助。
I've even added a "Nuget (command=restore)" task in my build pipeline.我什至在构建管道中添加了“Nuget (command=restore)”任务。 Its output shows that it has restored the Nuget packages into the solution's \\packages folder, but again no joy.
它的输出显示它已将 Nuget 包恢复到解决方案的 \\packages 文件夹中,但再次没有任何乐趣。
I've checked the relative package paths in the .csproj files and they correctly point to the packages folders restored by the above "Nuget restore" task.我检查了 .csproj 文件中的相对包路径,它们正确地指向由上述“Nuget 恢复”任务恢复的包文件夹。
Am I missing something or is the only fix to put the ".nuget" solution folder back?我是否遗漏了什么,或者是将“.nuget”解决方案文件夹放回的唯一修复方法?
Found the answer: I needed to remove remnants of the "old way" of package restore from each of my .csproj files, namely:找到答案:我需要从我的每个 .csproj 文件中删除包还原“旧方式”的残余,即:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
As per this SO answer: https://stackoverflow.com/a/23852183/981831根据这个 SO 答案: https : //stackoverflow.com/a/23852183/981831
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.