• <small id='GZTAe'></small><noframes id='GZTAe'>

  • <legend id='GZTAe'><style id='GZTAe'><dir id='GZTAe'><q id='GZTAe'></q></dir></style></legend>
    1. <i id='GZTAe'><tr id='GZTAe'><dt id='GZTAe'><q id='GZTAe'><span id='GZTAe'><b id='GZTAe'><form id='GZTAe'><ins id='GZTAe'></ins><ul id='GZTAe'></ul><sub id='GZTAe'></sub></form><legend id='GZTAe'></legend><bdo id='GZTAe'><pre id='GZTAe'><center id='GZTAe'></center></pre></bdo></b><th id='GZTAe'></th></span></q></dt></tr></i><div id='GZTAe'><tfoot id='GZTAe'></tfoot><dl id='GZTAe'><fieldset id='GZTAe'></fieldset></dl></div>
      <tfoot id='GZTAe'></tfoot>
        <bdo id='GZTAe'></bdo><ul id='GZTAe'></ul>

        将 Grunt、Bower、Gulp、NPM 与 Visual Studio 2015 一起用于 ASP.NET 4.5

        时间:2023-05-21

          <tbody id='TdnRc'></tbody>
        <tfoot id='TdnRc'></tfoot>

      1. <small id='TdnRc'></small><noframes id='TdnRc'>

        • <legend id='TdnRc'><style id='TdnRc'><dir id='TdnRc'><q id='TdnRc'></q></dir></style></legend>

              • <bdo id='TdnRc'></bdo><ul id='TdnRc'></ul>
                1. <i id='TdnRc'><tr id='TdnRc'><dt id='TdnRc'><q id='TdnRc'><span id='TdnRc'><b id='TdnRc'><form id='TdnRc'><ins id='TdnRc'></ins><ul id='TdnRc'></ul><sub id='TdnRc'></sub></form><legend id='TdnRc'></legend><bdo id='TdnRc'><pre id='TdnRc'><center id='TdnRc'></center></pre></bdo></b><th id='TdnRc'></th></span></q></dt></tr></i><div id='TdnRc'><tfoot id='TdnRc'></tfoot><dl id='TdnRc'><fieldset id='TdnRc'></fieldset></dl></div>
                  本文介绍了将 Grunt、Bower、Gulp、NPM 与 Visual Studio 2015 一起用于 ASP.NET 4.5 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  Visual Studio 2015 内置了对用于 ASP.NET 5 项目的 Grunt、Bower、Gulp 和 NPM 等工具的支持.

                  Visual Studio 2015 comes with built in support for tools like Grunt, Bower, Gulp and NPM for ASP.NET 5 projects.

                  但是,当我使用 Visual Studio 2015 创建 ASP.NET 4.5.2 项目时,它不使用这些工具.我想使用 bower 而不是 nuget 来管理客户端包.

                  However when I create a ASP.NET 4.5.2 project using Visual Studio 2015 it doesn't use these tools. I'd like to use bower instead of nuget to manage client side packages.

                  我可以找到有关在 Visual Studio 2013 中使用这些工具的信息(请参阅 this 问题为例).但我猜 Visual Studio 2015 的过程有所不同,因为它内置了对这些工具的支持.

                  I can find information about using these tools with Visual Studio 2013 (see this question for example). But I guess the procedure is different for Visual Studio 2015 since it has built in support for these tools.

                  推荐答案

                  虽然 Liviu Costea 的回答 是正确的,但它仍然我花了很长时间才弄清楚它是如何完成的.所以这是我从一个新的 ASP.NET 4.5.2 MVC 项目开始的分步指南.本指南包括使用 bower 进行客户端包管理,但(尚未)涵盖捆绑/grunt/gulp.

                  While Liviu Costea's answer is correct, it still took me quite some time to figure out how it is actually done. So here is my step-by-step guide starting from a new ASP.NET 4.5.2 MVC project. This guide includes client-side package management using bower but does not (yet) cover bundling/grunt/gulp.

                  使用 Visual Studio 2015 创建一个新的 ASP.NET 4.5.2 项目(MVC 模板).

                  Create a new ASP.NET 4.5.2 Project (MVC Template) with Visual Studio 2015.

                  卸载以下 Nuget 包:

                  Uninstall the following Nuget Packages:

                  • 引导
                  • Microsoft.jQuery.Unobtrusive.Validation
                  • jQuery.Validation
                  • jQuery
                  • Microsoft.AspNet.Web.Optimization
                  • WebGrease
                  • Antlr
                  • 现代化
                  • 回复

                  从项目中删除 App_StartBundleConfig.cs.

                  删除

                  using System.Web.Optimization;
                  

                  BundleConfig.RegisterBundles(BundleTable.Bundles);
                  

                  来自 Global.asax.cs

                  删除

                  <add namespace="System.Web.Optimization"/>
                  

                  来自 ViewsWeb.config

                  Web.config

                  在项目中添加新的package.json文件(NPM配置文件项模板)

                  Add new package.json file to project (NPM configuration file item template)

                  bower 添加到 devDependencies:

                  {
                    "version": "1.0.0",
                    "name": "ASP.NET",
                    "private": true,
                    "devDependencies": {
                      "bower": "1.4.1"
                    }
                  }
                  

                  保存package.json时会自动安装bower包.

                  The bower package is automatically installed when package.json is saved.

                  在项目中添加新的bower.json文件(Bower配置文件项模板)

                  Add new bower.json file to project (Bower Configuration file item template)

                  bootstrapjquery-validation-unobtrusivemodernizrrespond 添加到依赖项:

                  Add bootstrap, jquery-validation-unobtrusive, modernizr and respond to dependencies:

                  {
                    "name": "ASP.NET",
                    "private": true,
                    "dependencies": {
                      "bootstrap": "*",
                      "jquery-validation-unobtrusive": "*",
                      "modernizr": "*",
                      "respond": "*"
                    }
                  }
                  

                  保存bower.json时会自动安装这些包及其依赖项.

                  These packages and their dependencies are automatically installed when bower.json is saved.

                  替换

                  @Styles.Render("~/Content/css")
                  

                  <link rel="stylesheet" href="~/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css" />
                  <link rel="stylesheet" href="~/Content/Site.css" />
                  

                  步骤 5.2

                  替换

                  @Scripts.Render("~/bundles/modernizr")
                  

                  <script src="~/wwwroot/lib/modernizr/modernizr.js" ></script>
                  

                  步骤 5.3

                  替换

                  @Scripts.Render("~/bundles/jquery")
                  

                  <script src="~/wwwroot/lib/jquery/dist/jquery.min.js"></script>
                  

                  步骤 5.4

                  替换

                  @Scripts.Render("~/bundles/bootstrap")
                  

                  <script src="~/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js"></script>
                  <script src="~/wwwroot/lib/respond/dest/respond.min.js"></script>
                  

                  第 6 步(修改其他来源)

                  在所有其他视图中替换

                  Step 6 (Modify other sources)

                  In all other Views replace

                  @Scripts.Render("~/bundles/jqueryval")
                  

                  <script src="~/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js"></script>
                  <script src="~/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
                  


                  有用的链接

                  • http://idisposable.co.uk/2015/02/switching-the-client-side-build-library-in-visual-studio-2013-mvc-template-to-gulp-and-bower/
                  • http://www.baconapplications.com/running-bower-grunt-in-visual-studio-2013/
                  • https://web.archive.org/web/20190611132417/http://old.devkimchi.com:80/2015/01/06/integrating-grunt-and-bower-with-visual-studio-2013
                  • http://www.dotnetcurry.com/visualstudio/1096/using-grunt-gulp-bower-visual-studio-2013-2015
                  • http://andy-carter.com/blog/a-beginners-guide-to-package-manager-bower-and-using-gulp-to-manage-components
                  • http://www.jeffreyfritz.com/2015/05/where-did-my-asp-net-bundles-go-in-asp-net-5/
                  • 在下面的评论中 LavaHot 推荐 Bundler &缩小器扩展 作为我在步骤 2 中删除的默认捆绑器的替代品.他还推荐 这篇文章关于与 Gulp 捆绑.

                    In the comments below LavaHot recommends the Bundler & Minifier extension as a replacement for the default bundler which I remove in step 2. He also recommends this article on bundling with Gulp.

                    这篇关于将 Grunt、Bower、Gulp、NPM 与 Visual Studio 2015 一起用于 ASP.NET 4.5 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:.NET 的多线程与多处理:糟糕的 Parallel.ForEach 性能 下一篇:将 c# 中的 String^ 转换为 c++/CLI 中的 CString

                  相关文章

                      • <bdo id='Q7exx'></bdo><ul id='Q7exx'></ul>

                      <legend id='Q7exx'><style id='Q7exx'><dir id='Q7exx'><q id='Q7exx'></q></dir></style></legend>

                      <small id='Q7exx'></small><noframes id='Q7exx'>

                      <i id='Q7exx'><tr id='Q7exx'><dt id='Q7exx'><q id='Q7exx'><span id='Q7exx'><b id='Q7exx'><form id='Q7exx'><ins id='Q7exx'></ins><ul id='Q7exx'></ul><sub id='Q7exx'></sub></form><legend id='Q7exx'></legend><bdo id='Q7exx'><pre id='Q7exx'><center id='Q7exx'></center></pre></bdo></b><th id='Q7exx'></th></span></q></dt></tr></i><div id='Q7exx'><tfoot id='Q7exx'></tfoot><dl id='Q7exx'><fieldset id='Q7exx'></fieldset></dl></div>
                      <tfoot id='Q7exx'></tfoot>