簡體   English   中英

Azure DevOps 構建管道中的 NuGet 包還原

[英]NuGet package restore in Azure DevOps build pipeline

這是我昨天遇到的一個問題的后續: NuGet package restore in builds and Visual Studio

我已經從我的 VS2013 解決方案中刪除了“.nuget”解決方案文件夾,但是我的構建管道中的“Visual Studio 構建”任務現在失敗了,每個項目都有一個錯誤:

[錯誤]xxxxx.csproj(214,5):錯誤:此項目引用了此計算機上缺少的 NuGet 包。 啟用 NuGet 包還原以下載它們。 有關詳細信息,請參閱http://go.microsoft.com/fwlink/?LinkID=322105 丟失的文件是 c:\\Temp\\VSTS Agent_work\\10\\s\\xxxxx\\.nuget\\NuGet.targets。

我試過檢查 VS 構建任務中的“還原 NuGet 包”選項,但沒有區別。 該復選框表示此選項已棄用,要使用“Nuget 工具安裝程序”任務 - 我也嘗試過此操作,但仍然沒有幫助。

我什至在構建管道中添加了“Nuget (command=restore)”任務。 它的輸出顯示它已將 Nuget 包恢復到解決方案的 \\packages 文件夾中,但再次沒有任何樂趣。

我檢查了 .csproj 文件中的相對包路徑,它們正確地指向由上述“Nuget 恢復”任務恢復的包文件夾。

我是否遺漏了什么,或者是將“.nuget”解決方案文件夾放回的唯一修復方法?

找到答案:我需要從我的每個 .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>

根據這個 SO 答案: https : //stackoverflow.com/a/23852183/981831

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM