簡體   English   中英

如何在 Visual Studio 中使用 MSBuild 恢復 nuget 私人訂閱源

[英]How to restore nuget private feed using MSBuild in Visual Studio

我正在配置一個現有項目(dotnet 核心)以使用私有 nuget 存儲庫。 我已經使用以下結構設置了我的項目:

  • 項目1
  • 項目2
  • 項目3
  • .sln
  • nuget.config

如果我要運行“dotnet restore”命令但不能在使用 Visual Studio 的構建(MSBuild)時恢復我的包。

我希望能夠在使用 Visual Studio 的 MSBuild 時恢復我的 package。(不使用 cli)

如果可能的話,我想避免在構建之前使用 msbuild 的 Exec 任務來運行 dotnet restore。

  • 我已經在 Visual Studio 2017 和 2019 中嘗試過它們

您需要在實際目標之前運行 MSBuild Restore目標。 MSBuild.exe 提供了一種內置方式來執行此目標,然后刷新所有緩存(需要避免由於新恢復的包導致的增量構建問題),然后使用-r (long: -restore ) 參數執行實際構建:

例如:

msbuild -r -p:Configuration=Release the.sln

暫無
暫無

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

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