Visual Studio 2015 comes with built in support for tools like Grunt, Bower, Gulp and NPM for ASP.NET 5 projects.
However when I create a ASP.NET 4.5.2 project using
It is actually not too different. It is just that there is better support for all these inside Visual Studio, for example when you add new items you have templates for bower or npm config files. Also you have templates for gulp or grunt configuration files.
But the actually calling of grunt/gulp tasks and binding them to build events is still done with Task Runner Explorer, just like in VS 2013.
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.
Create a new ASP.NET 4.5.2 Project (MVC Template) with Visual Studio 2015.
Uninstall the following Nuget Packages:
Remove App_Start\BundleConfig.cs from project.
Remove
using System.Web.Optimization;
and
BundleConfig.RegisterBundles(BundleTable.Bundles);
from Global.asax.cs
Remove
<add namespace="System.Web.Optimization"/>
from Views\Web.config
Remove Assembly Bindings for System.Web.Optimization and WebGrease from Web.config
Add new package.json file to project (NPM configuration file item template)
Add bower to devDependencies:
{
"version": "1.0.0",
"name": "ASP.NET",
"private": true,
"devDependencies": {
"bower": "1.4.1"
}
}
The bower package is automatically installed when package.json is saved.
Add new bower.json file to project (Bower Configuration file item template)
Add bootstrap, jquery-validation-unobtrusive, modernizr and respond to dependencies:
{
"name": "ASP.NET",
"private": true,
"dependencies": {
"bootstrap": "*",
"jquery-validation-unobtrusive": "*",
"modernizr": "*",
"respond": "*"
}
}
These packages and their dependencies are automatically installed when bower.json is saved.
Views\Shared\_Layout.cshtml)Replace
@Styles.Render("~/Content/css")
with
<link rel="stylesheet" href="~/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/Content/Site.css" />
Replace
@Scripts.Render("~/bundles/modernizr")
with
<script src="~/wwwroot/lib/modernizr/modernizr.js" ></script>
Replace
@Scripts.Render("~/bundles/jquery")
with
<script src="~/wwwroot/lib/jquery/dist/jquery.min.js"></script>
Replace
@Scripts.Render("~/bundles/bootstrap")
with
<script src="~/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="~/wwwroot/lib/respond/dest/respond.min.js"></script>
In all other Views replace
@Scripts.Render("~/bundles/jqueryval")
with
<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>
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.