简体   繁体   中英

How to use nuget package in ASP.NET vNext?

I am giving asp.net vNext a go and have created a new project. I wanted to pull in some dependencies and used NuGet as I usually would. I used it to pull in Require.js for example.

I now have a reference to this under ASP.NET 5.0 in the project references and I can see the path to where it is on my drive from the properties (myUserDrive/.kpm/packages/require... blah)

My question is, how do I use this? - historically it would have added the code to my web project.

For clientside libraries you should now use Bower. The latest previews of Visual Studio 2015 have built in support for NodeJS' NPM packages and Bower packages. It's a bit more complicated but together with Grunt you can do some pretty cool stuff. Bower has a lot more libraries than NuGet and is more up to date.

For a good intro on all the new things in ASP.NET 5 I advise you to watch these videos on Channel 9: http://channel9.msdn.com/Series/Whats-New-with-ASPNET-5

The second video talks about NPM and Bower packages.

Bower: http://bower.io/ -> Search Packages

Visual Studio 2015 is allowing users to take advantage of popular open-source package management and build tools for processing client-side resources. They suggest using NuGet primarily for managing .NET packages.

The recommendations are:

Package Managers: NPM and Bower

NPM

Use Node Package Manager to install and manage build tools and plugins to compile source into client-side optimized files. NPM files are stored in "node_modules" (hidden in the VS project). Configured using "packages.json" .

Bower

Use the bower package manager to install and manage client libraries like "bootstrap", "jQuery", "angularjs". Bower files are stored in a folder named "bower_components" (hidden in VS project).
Configured using "bower.json" .

Build Tools: GruntJS and GulpJS

Grunt

Grunt is a javascript task runner which allows you to setup build tasks to process your source into client-side ready resources. Use NPM to install grunt plugins that allow you to compose tasks (such as processing LESS or coffee files or minifying js and css). Configured through "gruntfile.js" .

Gulp

Gulp is a "streaming build system". Similar to grunt but allows more advanced streaming tasks to be defined. Use NPM to install gulp plugins that allow you to compose tasks (such as processing LESS or coffee files or minifying js and css). Configured through "gulpfile.js" .

Visual Studio 2015 provides some built-in support for these tools, including autocomplete for package names and version numbers. Visual Studio will check to make sure your packages are installed and up-to-date when you open the project. Finally there is the "Task Runner" UI which allows you to run grunt or gulp tasks manually or configure them to trigger on certain events.

This following post gives an introductory step by step guide to using these tools in Visual Studio 2015. Beyond that you should be able to search on NPM, Bower, Gruntjs or Gulpjs to find intro videos or blog posts to help you become more familiar with each.

http://www.asp.net/vnext/overview/aspnet-vnext/grunt-and-bower-in-visual-studio-2015

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM