Message: “Use Library Manager instead”
Using ASP.NET Core, trying to get a client side library from the NuGet server, you’ll not be successful using the NuGet Package Manager. You might see an error as showing in the following picture, e.g. adding jQuery, Use Library Manager instead. From the NuGet description, the link references the GitHub repository from Library Manager.
You’ve different options on using the Library Manager now:
- Clone the GitHub repository, and build it
- Use the preview of Visual Studio 2017 15.8. The preview already includes the Library Manager.
While Bower is still maintained, the Bower website already recommends Yarn and Webpack for front-end projects. So, some time in the future you’ll switch. Maybe not now, maybe you wait for the Library Manager to be more ready.
To use Bower with your ASP.NET Core Web application, create a bower.json file using
In case you don’t have bower installed, you can install it with
npm install -g bower
In case you don’t have npm installed, get it from NPM.
As soon you’ve a
bower.json file in your project, you can select this file, and from the context menu choose Manage Bower Packages. Tool support similar to NuGet is available:
Use Library Manager
Using Visual Studio 2017 version 15.8 you can open the Library Manager by selecting the project in Solution Explorer and opening the context menu Manage Client-Side Libraries…. This creates a libman.json file:
Now you can add the libraries you need to the file
libman.json. IntelliSense is offered, and the server contacted to give you autocomplete with the list of libraries available. Using the
destination setting, you specify where the files should be stored. As you proabably don’t need all the files from the package, you can exactly specify the files that should be copied. As you save the file, the libraries are copied to the destination. From the Solution Explorer you also have the option Restore Client-Side Libraries from the context menu selecting libman.json.
|"files": ["jquery.js", "jquery.min.js", "jquery.min.map"]|
To automatically restore the libraries when the project is built, the NuGet package Microsoft.Web.LibraryManager.Build can be added. A menu in the context menu offers Enable Restore on Build which adds this NuGet package.
The Library Manager also supports checking for updates directly from a light bulb when working with libman.json:
Some features are still missing, but I expect more and more features coming with the Library Manager. The Roadmap shows a UI is coming to manage libraries. Working with the JSON file is fine for me 🙂
In case you don’t want to use preview versions of Library Manager and Visual Studio, you can keep working with Bower in the meantime.
Enjoy programming and learning,