Visual studio multi project template restore all nuget packages

不羁岁月 提交于 2019-12-25 12:09:36

问题


I´m strugling around for some days with visual studio multi project templates installed by an vsix plugin.

What I tried: Stackoverflow 1 AND TONS OF MSDN ARTICLES

The problem/what I want to do:

  1. Setup a private nuget feed for visual studio in general.
  2. Install packages from this feed to the subprojects

I thought about using the nuget package restore command, because all the subprojects have their packages.config files but I have no plan how to run that command after the project was created. Is there a way to start e.g. a powershell script that perform such tasks for me?

thanks & greetings Nico


回答1:


If this is part of your own custom VSIX extension, you might want to consider using NuGet via C# itself via NuGet.Core or NuGet.VisualStudio.

You could create your own IWizard and list the packages in the <WizardData> element in your MyTemplate.vstemplate definition file.

Although it is using the official NuGet v2 URL, I took this approach to make sure when ever users create a new ServiceStack project via ServiceStackVS, it installs the latest version across all the projects.

The NuGetPackageInstallerMultiProjectWizard class is for use on multi-project templates and checks for the latest version of a specific NuGet dependency specified in the <WizardData> of the parent template. While the NuGetPackageInstallerWizard is responsible for actually installing the NuGet dependency.

So if you know the URL users will need to use for the required NuGet packages you could take a similar approach.



来源:https://stackoverflow.com/questions/32331655/visual-studio-multi-project-template-restore-all-nuget-packages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!