问题
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)?
回答1:
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):
来源:https://stackoverflow.com/questions/57804370/nuget-package-restore-in-builds-and-visual-studio