Visual Studio: Bower is Dead Long Live LibMan

rip_bower.pngSo, Bower is dead for Visual Studio.  NPM and WebPack are external tools and overkill if all you really want to do is add a simple open source project like Bootstrap-Datepicker.

As of Visual Studio 2017.7, you can use a Visual Studio tool to get client side libraries.

The goal of this tutorial is to include Bootstrap-Datepicker, a popular javascript open source project.

Step 1: Turn on Library Manager by right clicking the Project and choosing Manage Client-side libraries

libman1.png

A new file called LibMan.json is added. If you open it you’ll see this:

libman2.png

By default LibMan.json uses the content provider “CDNJS” to provide the JS. Other providers are available. Remember this isn’t a CDN, it’s just where to download the JS from.

Let’s add a defaultDestination for our packages:

libman3.png

Step 2: To add a library, go to cdnjs.com and find the package, for example:

https://cdnjs.com/libraries/bootstrap-datepicker

We now know the name of the package “bootstrap-datepicker”.  Add that and use a @ at the end to get intellisence for the version number:

libman4.png

Save the file, then right click libman.json and choose Enable Restore on Build to have a NuGet package added which will cause MSBuild to download JS packages.

Build the solution and you’ll see bootstrap-datepicker.js added.

libman5.png


That’s the fastest way to get started, here’s some more documentation for finer control.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s