是否创建一个已经包含Nuget包参考的Visual Studio项目模板? [英] Creating a Visual Studio Project Template that already includes a Nuget Package Reference?

查看:143
本文介绍了是否创建一个已经包含Nuget包参考的Visual Studio项目模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Visual Studio 2010项目模板,该模板本质上是一个ASP.net 3.5 Webforms应用程序.

I want to create a Visual Studio 2010 Project Template, which is essentially a ASP.net 3.5 Webforms Application.

但是,我想自动添加一个NuGet包参考.我可以根据需要将实际的nupkg与模板捆绑在一起,但是我想知道是否可以在创建新项目时改为运行Install-Package命令以始终检索最新版本? (我可以保证以后的版本永远不会破坏模板)

However, I would like to automatically add a NuGet Package Reference. I can bundle the actual nupkg with the template if needed, but I wonder if it's possible to instead run the Install-Package command to always retrieve the latest version when creating a new Project? (I can guarantee that future versions never break the template)

有可能吗?到目前为止,我仅对项目模板进行了少量更改,所以我不知道确切的开始位置.我为MVC 3找到了一些东西,但是如上所述,我在Webforms(和.net 3.5)上.

Is that possible? I only made small changes to Project Templates so far, so I don't know exactly where I would start. I found some stuff for MVC 3, but as said, I'm on Webforms (and .net 3.5).

推荐答案

您可以为其创建自定义模板,但是不会从网络上获取它,它只会从本地磁盘复制(尽管也许将来会改变). Phil Haack写了 在他的博客上最近关于此的文章:

You can create a custom template for it, however it won't be fetched from the web, it'll only copy from your local disk (though maybe this will change in the future). Phil Haack wrote an article about this on his blog recently:

有两个主要限制:

There are two major limitations:

  • 该程序包必须存在于%ProgramFiles%\ Microsoft ASP.NET \ ASP.NET MVC 3 \ Packages文件夹中. MVC 3不会在线搜索它们.
  • 该元素中软件包的version属性是必需的,并且是完全匹配的.

这篇关于是否创建一个已经包含Nuget包参考的Visual Studio项目模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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