简体   繁体   中英

NuGet package restore in builds and Visual Studio

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.

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?

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.

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:

在此处输入图片说明

In fact, VS should do it automatically when you build, if not check this setting (under Tools - Options):

在此处输入图片说明

You need to add your private NuGet feed to the NuGet sources (Tools - Options):

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM