Skip to content

Using LibMan in a CI Build

Jimmy Lewis edited this page Nov 29, 2025 · 3 revisions

Restoring libraries with LibMan during CI builds

There are two ways to restore files during CI builds:

  1. Using the LibMan MSBuild package
  2. Using the LibMan CLI tool

LibMan MSBuild package

Simply install the Microsoft.Web.LibraryManager.Build package in your project. This package includes a build task that will restore the libman.json manifest during the build. Note that package only supports when your libman.json file is in the same directory as your .csproj file.

See LibMan MSBuild Reference for details.

LibMan CLI tool

You can run the CLI tool as a step before building your .NET project. The CLI tool does not require a .csproj file, so you can use this to restore files anywhere you have a libman.json file.

See LibMan CLI Reference for details about the CLI tool.

Example using Azure Pipelines:

# Install the CLI tool
- task: DotNetCoreCLI@2
  displayName: 'Install LibMan CLI'
  inputs:
    command: custom
    custom: tool
    arguments: 'install -g Microsoft.Web.LibraryManager.Cli'

# Restore
- task: CmdLine@2
  displayName: 'Run LibMan Restore'
  inputs:
    script: 'libman restore'
    workingDirectory: '<path to the directory where your libman.json is located>'

Example using GitHub Actions:

# Install LibMan CLI globally
- name: Install LibMan CLI
  run: dotnet tool install -g Microsoft.Web.LibraryManager.Cli

# Restore libraries using LibMan
- name: Run LibMan Restore
  run: libman restore
  working-directory: '<path to the directory where your libman.json is located>'

Other considerations

Caching

In order to speed up CI builds, you may want to store the LibMan cache for reuse in your CI pipeline. Some CI platforms allow this, such as Azure Pipelines' cache@v2 task (docs), or GitHub Actions' cache action (docs).

Clone this wiki locally