msbuild-server
dotnet/skills
Enable MSBuild Server caching for faster incremental CLI builds in .NET projects.
What is msbuild-server?
MSBuild Server caches evaluation results across sequential CLI builds, matching the performance advantage Visual Studio gets from its long-lived process. Use this when incremental builds from the command line are slower than expected or noticeably slower than IDE builds.
- Caches MSBuild evaluation results across CLI builds to reduce redundant work
- Enables persistent server-based caching via MSBUILDUSESERVER=1 environment variable
- Provides measurable speedup on second and subsequent builds of the same project
- Most effective for repos with many projects or complex Directory.Build.props chains
- Allows shutdown and restart of the build server for troubleshooting
How to install msbuild-server
npx skills add https://github.com/dotnet/skills --skill msbuild-server- MSBuild Server support (available in recent .NET SDK versions)
- Command-line build context (not applicable to IDE-based builds)
How to use msbuild-server
- 1.Verify you are building from the command line (dotnet build), not from Visual Studio or another IDE
- 2.Set the MSBUILDUSESERVER=1 environment variable in your shell (bash: export MSBUILDUSESERVER=1; PowerShell: $env:MSBUILDUSESERVER = "1"; Windows persistent: setx MSBUILDUSESERVER 1)
- 3.Run two sequential builds of the same project and compare times: first build (cold) starts the server, second build (warm) should be noticeably faster
- 4.If build correctness issues occur, run dotnet build-server shutdown to reset and disable the server if problems persist
Use cases
- Speed up local development workflows with frequent incremental CLI builds
- Accelerate CI pipelines that run multiple sequential builds of the same repository
- Match Visual Studio build performance when developers switch between IDE and command-line builds
- Reduce build times in monorepos with complex project dependencies
- Backend developers using .NET CLI for local builds
- CI/CD engineers optimizing build pipeline performance
- Teams with slow incremental builds from the command line
msbuild-server FAQ
No. Visual Studio already uses a long-lived MSBuild process, so the server provides no additional benefit for IDE-based builds.
The improvement depends on project complexity. Repos with many projects or complex Directory.Build.props chains see the most noticeable speedup on warm builds (second and subsequent builds).
Run dotnet build-server shutdown to stop the server process. It will restart automatically on the next build if MSBUILDUSESERVER=1 is still set.
Disable it if you suspect build correctness issues. Run dotnet build-server shutdown and rebuild to isolate the problem.
The server persists in the background and can be shut down with dotnet build-server shutdown when idle to free resources.
Full instructions (SKILL.md)
Source of truth, from dotnet/skills.
name: msbuild-server description: "Guide for using MSBuild Server to improve CLI build performance. 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)." license: MIT
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 / 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:
- First build (cold):
dotnet build-- server starts, no cache benefit - 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=1is set in the shell - Second sequential build is faster than the first
-
dotnet build-server shutdownfollowed 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 |
Related skills
More from dotnet/skills and the wider catalog.

mtp-hot-reload
Set up and run MTP hot reload for iterative test fixing in a persistent console host.

nuget-trusted-publishing
Set up NuGet trusted publishing (OIDC) on GitHub Actions—replace API keys with short-lived tokens.

optimizing-ef-core-queries
Diagnose and fix slow Entity Framework Core queries by reading generated SQL and applying targeted optimizations.

plan-ui-change
Decompose complex Blazor UIs into focused, composable components with a structured planning workflow.

platform-detection
Identify .NET project test platform (VSTest or MTP), framework (MSTest/xUnit/NUnit/TUnit), and project system type.

property-patterns
MSBuild property definition patterns: conditional defaults, composition, path normalization, and evaluation order.