Libman

Library Manager (LibMan) is a lightweight, client-side library acquisition tool. LibMan downloads popular libraries and frameworks from the file system or from a content delivery network (CDN)

After creating a new ASP.NET Core Web App, it will pull down assets into wwwroot\lib, these are normally excluded from source control in .gitignore by the lib folder.

My process is then:

  1. Rename wwwroot\lib as wwwroot\lib2
  2. Create a libman.json file in the root, this can be manual or use Visual Studio but right clicking the solution and selecting Manage Client-Side Libraries... which creates libman.json manually.

Manage client side libraries

  1. Once the file exists, you can either edit it manually or using Visual Studio, in solution explorer, right-click the folder wwwroot and choose Add > Client-Side Library

Add client side library

Inspect the contents of wwwroot\lib2 adding back the libs, examples

  • bootstrap
  • jquery
  • jquery-validate
  • jquery-validation-unobtrusive

Restore Client-Side Libraries

  1. Pay attention to make sure the directories match, some go in dist folders.

My complete libman.json file is then

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"version": "3.0",
"defaultProvider": "cdnjs",
"libraries": [
{
"library": "bootstrap@5.1.0",
"destination": "wwwroot/lib/bootstrap/dist"
},
{
"library": "jquery@3.6.0",
"destination": "wwwroot/lib/jquery/dist"
},
{
"library": "jquery-validate@1.21.0",
"destination": "wwwroot/lib/jquery-validation/dist"
},
{
"library": "jquery-validation-unobtrusive@4.0.0",
"destination": "wwwroot/lib/jquery-validation-unobtrusive"
}
]
}
  1. Delete lib2 and make sure the app still works as expected.

References