Agent skill

msbuild-server

Guide for using MSBuild Server to improve CLI build performance. Only activate in MSBuild/.NET build context. Activate when developers report slow incremental builds from the command line, or when CLI builds are noticeably slower than IDE builds. Covers MSBUILDUSESERVER=1 environment variable for persistent server-based caching. Do not activate for IDE-based builds (Visual Studio already uses a long-lived process).

Stars 302
Forks 22

Install this agent skill to your Project

npx add-skill https://github.com/managedcode/dotnet-skills/tree/main/catalog/Tools/Official-DotNet-MSBuild/skills/msbuild-server

SKILL.md

MSBuild Server for CLI Caching

Use the MSBuild Server to cache evaluation results across CLI builds, matching the performance advantage Visual Studio gets from its long-lived MSBuild process.

When to Use

  • Small incremental builds from CLI (dotnet build) are slower than expected
  • Developers notice that VS builds are faster than CLI builds for the same project
  • CI agents run many sequential builds of the same repo

When Not to Use

  • IDE-based builds (Visual Studio already uses a long-lived MSBuild process)
  • One-off builds where cold-start overhead is acceptable
  • Build correctness issues are suspected (disable the server to isolate the problem)

Inputs

Input Required Description
Shell context No The shell where the environment variable will be set (bash, PowerShell, or Windows persistent)

Workflow

Step 1: Confirm CLI context

Verify the developer is building from the command line (dotnet build), not from Visual Studio or another IDE. The MSBuild Server provides no benefit inside an IDE.

Step 2: Set the environment variable

bash
# Bash / CI
export MSBUILDUSESERVER=1

# PowerShell
$env:MSBUILDUSESERVER = "1"

# Windows (persistent)
setx MSBUILDUSESERVER 1

Step 3: Validate improvement

Run two sequential builds of the same project and compare times:

  1. First build (cold): dotnet build -- server starts, no cache benefit
  2. Second build (warm): dotnet build -- should be noticeably faster

The most noticeable improvement is in repos with many projects or complex Directory.Build.props chains.

Validation

  • MSBUILDUSESERVER=1 is set in the shell
  • Second sequential build is faster than the first
  • dotnet build-server shutdown followed by a rebuild confirms the server restarts cleanly

Common Pitfalls

Pitfall Solution
Expecting improvement in Visual Studio VS already uses long-lived MSBuild nodes; the server adds no benefit
Build correctness issues after enabling Run dotnet build-server shutdown to reset; if issues persist, disable the server
Server process using unexpected memory The server persists in background; shut down with dotnet build-server shutdown when idle

Expand your agent's capabilities with these related and highly-rated skills.

managedcode/dotnet-skills

dotnet-project-setup

Create or reorganize .NET solutions with clean project boundaries, repeatable SDK settings, and a maintainable baseline for libraries, apps, tests, CI, and local development.

302 22
Explore
managedcode/dotnet-skills

csharp-scripts

Run single-file C# programs as scripts (file-based apps) for quick experimentation, prototyping, and concept testing. Use when the user wants to write and execute a small C# program without creating a full project.

302 22
Explore
managedcode/dotnet-skills

dotnet-pinvoke

Correctly call native (C/C++) libraries from .NET using P/Invoke and LibraryImport. Covers function signatures, string marshalling, memory lifetime, SafeHandle, and cross-platform patterns. USE FOR: writing new P/Invoke or LibraryImport declarations, reviewing or debugging existing native interop code, wrapping a C or C++ library for use in .NET, diagnosing crashes, memory leaks, or corruption at the managed/native boundary. DO NOT USE FOR: COM interop, C++/CLI mixed-mode assemblies, or pure managed code with no native dependencies.

302 22
Explore
managedcode/dotnet-skills

nuget-trusted-publishing

Set up NuGet trusted publishing (OIDC) on a GitHub Actions repo — replaces long-lived API keys with short-lived tokens. USE FOR: trusted publishing, NuGet OIDC, keyless NuGet publish, migrate from NuGet API key, NuGet/login, secure NuGet publishing. DO NOT USE FOR: publishing to private feeds or Azure Artifacts (OIDC is nuget.org only). INVOKES: shell (powershell or bash), edit, create, ask_user for guided repo setup.

302 22
Explore
managedcode/dotnet-skills

dotnet-legacy-aspnet

Maintain classic ASP.NET applications on .NET Framework, including Web Forms, older MVC, and legacy hosting patterns, while planning realistic modernization boundaries.

302 22
Explore
managedcode/dotnet-skills

dotnet-code-review

Review .NET changes for bugs, regressions, architectural drift, missing tests, incorrect async or disposal behavior, and platform-specific pitfalls before you approve or merge them.

302 22
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results