NuGet软件包在内部版本和Visual Studio中还原 [英] NuGet package restore in builds and Visual Studio
问题描述
我们有许多VS2013解决方案,都选择了启用NuGet软件包还原"选项.回想一下,选择此选项将创建一个".nuget"解决方案文件夹,其中包含许多文件(NuGet.config,NuGet.exe,NuGet.targets).最后,我将编辑NuGet.targets
文件,为我们的内部仓库添加软件包源.
We have a number of VS2013 solutions, with the "Enable NuGet package restore" option selected. Remembering back, selecting this option creates a ".nuget" solution folder containing a number of files (NuGet.config, NuGet.exe, NuGet.targets). As a final step, I would edit the NuGet.targets
file to add a package source for our in-house repo.
我刚刚将旧的TFS2012服务器升级到Azure DevOps 2019,并且当前正在创建新的构建管道以替换旧的基于XAML的构建定义.我添加了"NuGet恢复"任务,但是由于我们的解决方案启用了打包恢复"选项,因此我不确定是否有必要这样做?如果删除此任务,将改为通过"Visual Studio构建"任务还原软件包吗?
I've just upgraded our old TFS2012 server to Azure DevOps 2019 and am currently creating new build pipelines to replace our old XAML-based build definitions. I've added a "NuGet restore" task, but I'm not sure if this is necessary given that our solutions have the "package restore" option enabled? If I remove this task, will the packages be restored by the "Visual Studio build" task instead?
我从不真正喜欢让所有软件包还原解决方案中的内容.如果要删除它,我猜毕竟还是需要"NuGet恢复"构建任务吗?但是如果没有软件包还原选项,开发人员将如何在PC上(在VS2019中)还原软件包?
I never really liked having all that package restore stuff in the solution. If I was to remove it, I guess the "NuGet restore" build task would be needed after all? But without the package restore option, how would a developer restore the packages on their PC (in VS2019)?
推荐答案
最佳实践是在构建管道中完成两项任务-恢复和构建.
The best practice is to make two tasks in the build pipeline - restore and build.
VS2015中不再存在启用NuGet软件包还原"选项,那么开发人员如何还原软件包?只需右键单击解决方案,然后选择还原NuGet软件包:
The option "Enable NuGet package restore" does not exist anymore from VS2015, so how the developer restore the packages? just right-click on the solution and "Restore NuGet Packages:
实际上,VS应该在构建时自动执行,如果不检查此设置(在工具"-选项"下):
In fact, VS should do it automatically when you build, if not check this setting (under Tools - Options):
您需要将您的私人NuGet提要添加到NuGet源(工具-选项):
You need to add your private NuGet feed to the NuGet sources (Tools - Options):
这篇关于NuGet软件包在内部版本和Visual Studio中还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!