I give you two answers. NPM in combination with other tools is powerful, but requires configuration to configure. If you just want to download some libraries, you can use the library manager instead (released in Visual Studio 15.8).
NPM (Advanced)
First add package.json to the root directory of your project. Add the following content:
{ "version": "1.0.0", "name": "asp.net", "private": true, "devDependencies": { "gulp": "3.9.1", "del": "3.0.0" }, "dependencies": { "jquery": "3.3.1", "jquery-validation": "1.17.0", "jquery-validation-unobtrusive": "3.2.10", "bootstrap": "3.3.7" } }
This will force NPM to load Bootstrap, JQuery, and other libraries used in the new asp.net base project into a folder named node_modules. The next step is to copy the files to the appropriate location. For this, we will use gulp, which was also loaded by NPM. Then add a new file to the root directory of your project called gulpfile.js . Add the following content:
/// <binding AfterBuild='default' Clean='clean' /> /* This file is the main entry point for defining Gulp tasks and using Gulp plugins. Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007 */ var gulp = require('gulp'); var del = require('del'); var nodeRoot = './node_modules/'; var targetPath = './wwwroot/lib/'; gulp.task('clean', function () { return del([targetPath + '/**/*']); }); gulp.task('default', function () { gulp.src(nodeRoot + "bootstrap/dist/js/*").pipe(gulp.dest(targetPath + "/bootstrap/dist/js")); gulp.src(nodeRoot + "bootstrap/dist/css/*").pipe(gulp.dest(targetPath + "/bootstrap/dist/css")); gulp.src(nodeRoot + "bootstrap/dist/fonts/*").pipe(gulp.dest(targetPath + "/bootstrap/dist/fonts")); gulp.src(nodeRoot + "jquery/dist/jquery.js").pipe(gulp.dest(targetPath + "/jquery/dist")); gulp.src(nodeRoot + "jquery/dist/jquery.min.js").pipe(gulp.dest(targetPath + "/jquery/dist")); gulp.src(nodeRoot + "jquery/dist/jquery.min.map").pipe(gulp.dest(targetPath + "/jquery/dist")); gulp.src(nodeRoot + "jquery-validation/dist/*.js").pipe(gulp.dest(targetPath + "/jquery-validation/dist")); gulp.src(nodeRoot + "jquery-validation-unobtrusive/dist/*.js").pipe(gulp.dest(targetPath + "/jquery-validation-unobtrusive")); });
This file contains JavaScript code that runs when building and cleaning up the project. It will copy all the necessary files to lib2 ( not to lib - you can easily change this ). I used the same structure as in the new project, but it is easy to change it to another place. If you are moving files, be sure to update _Layout.cshtml as well. Please note that all files in the lib2 directory will be deleted when the project is cleaned.
If you right-click on gulpfile.js , you can select Task Runner Explorer . From here, you can run gulp manually to copy or clean files.
Gulp can also be useful for other tasks, such as minimizing JavaScript and CSS files:
https://docs.microsoft.com/en-us/aspnet/core/client-side/using-gulp?view=aspnetcore-2.1
Library Manager (Simple)
Right-click on your project and select Manage Client Libraries . The libman.json file is now open. In this file you specify which library and files to use and where they should be stored locally. Really easy! The following file copies the default libraries that are used when creating a new ASP.NET Core 2.1 project:
{ "version": "1.0", "defaultProvider": "cdnjs", "libraries": [ { "library": "jquery@3.3.1", "files": [ "jquery.js", "jquery.min.map", "jquery.min.js" ], "destination": "wwwroot/lib/jquery/dist/" }, { "library": "jquery-validate@1.17.0", "files": [ "additional-methods.js", "additional-methods.min.js", "jquery.validate.js", "jquery.validate.min.js" ], "destination": "wwwroot/lib/jquery-validation/dist/" }, { "library": "jquery-validation-unobtrusive@3.2.10", "files": [ "jquery.validate.unobtrusive.js", "jquery.validate.unobtrusive.min.js" ], "destination": "wwwroot/lib/jquery-validation-unobtrusive/" }, { "library": "twitter-bootstrap@3.3.7", "files": [ "css/bootstrap.css", "css/bootstrap.css.map", "css/bootstrap.min.css", "css/bootstrap.min.css.map", "css/bootstrap-theme.css", "css/bootstrap-theme.css.map", "css/bootstrap-theme.min.css", "css/bootstrap-theme.min.css.map", "fonts/glyphicons-halflings-regular.eot", "fonts/glyphicons-halflings-regular.svg", "fonts/glyphicons-halflings-regular.ttf", "fonts/glyphicons-halflings-regular.woff", "fonts/glyphicons-halflings-regular.woff2", "js/bootstrap.js", "js/bootstrap.min.js", "js/npm.js" ], "destination": "wwwroot/lib/bootstrap/dist" }, { "library": "list.js@1.5.0", "files": [ "list.js", "list.min.js" ], "destination": "wwwroot/lib/listjs" } ] }
If you are moving files, be sure to update _Layout.cshtml as well.