LibMan is a lightweight tool for managing client side libraries. It is integrated in Visual Studio 2017+ or it can be installed as a .NET tool using the following command:

dotnet tool install --global Microsoft.Web.LibraryManager.Cli

To set up LibMan, go to your project’s root directory and run this:

libman init

This creates a libman.json file which looks like this:

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": []
}

You can then customize the libman file with the libraries you want to use:

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "defaultDestination": "wwwroot",
  "libraries": 
  [
    {
      "library": "bootstrap@5.3.1",
      "files": 
      [
        "css/bootstrap.min.css",
        "js/bootstrap.bundle.min.js"
      ],
      "destination": "wwwroot/lib"
    }
  ]
}

In this example, I’ve configured libman to source the files from cdnjs and place them into the wwwroot folder by default.

However, in the libraries array, I’m overriding the default destination and I’m specifying that I only want the minified bootstrap css and js bundle.

Now, you need to run this:

libman restore

And libman will download the specified files to their destination.

libman also provides several utility commands such as:

  • libman clean which deletes all files defined in libman.json
  • libman install which lets you add a new library through the command line
  • libman uninstall which lets you delete a library through the command line
  • libman update which lets you update a library through the command line

LibMan is great if you need to manage a small number of libraries and are not currently using any other package manager. However, if you need more advanced configurations, you will most likely need to use a full featured package manager such as npm or yarn.