visual-studio 在新版本的 jQuery(和其他库)上更新 Visual Studio 模板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2916016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
updating Visual Studio templates on new release of jQuery (and other libraries)
提问by Chase Florell
Now that Visual Studio => 2010 has jQuery support, I'm wondering how I can update the project template when a new jQuery release comes out? Currently when you create a project, it automatically creates the 1.4.1 files (in VS2010), but jQuery is ever evolving, and often updates it version.
现在 Visual Studio => 2010 有 jQuery 支持,我想知道如何在新的 jQuery 版本发布时更新项目模板?目前,当您创建一个项目时,它会自动创建 1.4.1 文件(在 VS2010 中),但 jQuery 一直在发展,并且经常更新它的版本。
How can I tell Visual Studio to use the more recent version of jQuery (or other libraries for that matter)?
如何告诉 Visual Studio 使用更新版本的 jQuery(或其他库)?
回答by Jboy Flaga
You can use NuGet
您可以使用 NuGet
- right-click on your project in Solution Explorer
- click on "Manage NuGet Packages" in context menu
- type "jQuery" in the search box on the top right corner of the dialog box
- press Enter key and wait for results
- look for "jQuery" in the results, SELECT it and click "Install" button
- (after installation, you previous jquery and related files will be replaced with the latest ones)
- 在解决方案资源管理器中右键单击您的项目
- 单击上下文菜单中的“管理 NuGet 包”
- 在对话框右上角的搜索框中输入“jQuery”
- 按 Enter 键并等待结果
- 在结果中查找“jQuery”,选择它并单击“安装”按钮
- (安装后,你之前的jquery和相关文件会被替换成最新的)
Alternatively, you can create an Empty project and install the the nuget package(s) through the Package Manager Console. This can include ALL of the libraries that you default to.
或者,您可以创建一个空项目并通过包管理器控制台安装 nuget 包。这可以包括您默认使用的所有库。
PM> Install-Package jQuery
PM> Install-Package jQuery
From there, save it as a new template, and whenever you create a new project, simply run the following terminal command before starting work.
从那里,将其另存为新模板,无论何时创建新项目,只需在开始工作前运行以下终端命令即可。
PM> Update-Package
PM> Update-Package
more info on Update-Package
有关更新包的更多信息
回答by Dave Swersky
You can create a new project template with jQuery 1.4.2 included: http://msdn.microsoft.com/en-us/library/ms247120%28v=VS.100%29.aspx
您可以创建包含 jQuery 1.4.2 的新项目模板:http: //msdn.microsoft.com/en-us/library/ms247120%28v=VS.100%29.aspx
回答by azamsharp
Automatic update have some issues. If you are using jQuery library with some additional plugin and they depend on the previous jQuery library framework then they will not work. That is why you need to think carefully before updating the jQuery library from version to version.
自动更新有一些问题。如果您使用带有一些附加插件的 jQuery 库,并且它们依赖于以前的 jQuery 库框架,那么它们将无法工作。这就是为什么在从版本到版本更新 jQuery 库之前需要仔细考虑的原因。
UPDATE:
更新:
You could modify an existing template for Visual Studio which will allow you to refer to the new version of jQuery. Here is an article about creating custom Visual Studio templates.
您可以修改 Visual Studio 的现有模板,这将允许您引用新版本的 jQuery。这是一篇关于创建自定义 Visual Studio 模板的文章。
http://msdn.microsoft.com/en-us/library/ms247119(v=VS.80).aspx
http://msdn.microsoft.com/en-us/library/ms247119(v=VS.80).aspx
回答by Stokely
This whole Nuget/update version model in JQuery is a huge mess! (Who designed this system?)
JQuery 中的整个 Nuget/更新版本模型是一团糟!(这个系统是谁设计的?)
What I do is simply avoid the JQuery template piece in Visual Studio and place the current JQuery javascript links in ONE PLACE in your web project so its pasted into every single page......either the MVC Layout page, usercontrol, or masterpage. You can mix and match controls. But it doesnt matter as modern browsers cache these files after the first download anyway.
我所做的只是避免在 Visual Studio 中使用 JQuery 模板块,并将当前的 JQuery javascript 链接放在您的 web 项目中的一个地方,以便将其粘贴到每个页面中……MVC 布局页面、用户控件或母版页. 您可以混合和匹配控件。但没关系,因为现代浏览器在第一次下载后缓存这些文件。
Now when you do a JQuery update, you can fix it in one simple place in your web project. All ECMAscripts have been done this way anyway the past 15 years using server side includes or other strategies. I'm still not sure why you want a template to stuff links in hundreds of view pages in MVC you now have to customize one by one when you get different versioned files names. I think ASP.NET MVC has gone backwards in its design for that reason.
现在,当您执行 JQuery 更新时,您可以在 Web 项目中的一个简单位置修复它。在过去的 15 年里,所有 ECMA 脚本都是通过这种方式使用服务器端包含或其他策略完成的。我仍然不确定为什么您需要一个模板来填充 MVC 中数百个视图页面中的链接,现在当您获得不同版本的文件名时,您必须逐个自定义。由于这个原因,我认为 ASP.NET MVC 在其设计上已经倒退了。

