简体   繁体   English

Azure DevOps 构建管道中的 NuGet 包还原

[英]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.

相关问题 NuGet 恢复任务在 azure devops 构建管道中失败 - The NuGet Restore task is getting failed in azure devops build pipeline Azure devops 构建管道似乎两次恢复 nuget 包 - Azure devops build pipeline seems to restore nuget packages twice 从构建或发布管道在 azure devops 中发布 nuget 包 - Publish nuget package in azure devops from build or release pipeline Azure DevOps Pipeline 上的 Nuget 还原失败 - Nuget Restore fails on Azure DevOps Pipeline Azure DevOps Pipeline 在 NuGet 恢复任务中失败 - Azure DevOps Pipeline failing at NuGet restore task 自托管 MacOS 代理上的 DevOps 管道在 NuGet package 恢复但适用于 Azure 管道上失败 - DevOps pipeline on self-hosted MacOS agent fails on NuGet package restore but works on Azure Pipeline 如何在 Azure 管道中恢复 NuGet package? - How to restore NuGet package in Azure Pipeline? 如何将预发布 NuGet 包的最新版本还原为 Azure DevOps 构建的一部分 - How to restore the latest version of a pre-release NuGet package as part of an Azure DevOps build 使用私有包源在 Azure DevOps 中构建的 Dotnet 无法从私有 nuget 源恢复 - Dotnet build in Azure DevOps with private package source cannot restore from private nuget feed Azure DevOps Nuget 管道步骤中的 Nuget 包描述 - Nuget package description in the Azure DevOps Nuget pipeline step
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM