Visual Studio 多项目模板还原所有 nuget 包 [英] Visual studio multi project template restore all nuget packages

查看:35
本文介绍了Visual Studio 多项目模板还原所有 nuget 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 vsix 插件安装的 Visual Studio 多项目模板苦苦挣扎了几天.

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

我尝试过的:Stackoverflow 1和大量的 MSDN 文章

What I tried: Stackoverflow 1 AND TONS OF MSDN ARTICLES

问题/我想做什么:

  1. 通常为 Visual Studio 设置私人 nuget 提要.
  2. 将此提要中的包安装到子项目

我考虑过使用 nuget package restore 命令,因为所有子项目都有它们的 packages.config 文件,但我没有计划在项目创建后如何运行该命令.有没有办法开始,例如为我执行此类任务的 powershell 脚本?

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

推荐答案

如果这是您自己的自定义 VSIX 扩展的一部分,您可能需要考虑通过 NuGet.CoreNuGet.VisualStudio.

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.

您可以创建自己的 IWizard 并在 MyTemplate.vstemplate 定义文件中的 元素中列出包.

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

虽然它使用官方的 NuGet v2 URL,但我采用这种方法来确保用户通过 ServiceStackVS 创建新的 ServiceStack 项目时,它会在所有项目中安装最新版本.

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.

NuGetPackageInstallerMultiProjectWizard 类用于多项目模板,并检查父模板的 中指定的特定 NuGet 依赖项的最新版本.而 NuGetPackageInstallerWizard 负责实际安装 NuGet 依赖项.

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.

因此,如果您知道用户需要用于所需 NuGet 包的 URL,您可以采用类似的方法.

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

这篇关于Visual Studio 多项目模板还原所有 nuget 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆