Build time becomes noticeable when a .NET solution contains many projects, source generators, analyzers, custom MSBuild targets, and several project-to-project dependencies. Even when the actual compilation is incremental, repeatedly starting the build infrastructure can add overhead to every command.

The MSBuild Server addresses this part of the problem by keeping a long-running MSBuild process available between compatible command-line builds. Instead of creating the required MSBuild context from scratch for every invocation, later builds can reuse the existing process and cached information.

This is especially useful during local development, where developers may run dotnet build, dotnet test, or related commands many times during a short development session.

The important point is that MSBuild Server does not make the C# compiler magically faster. Its main purpose is to reduce repeated startup and initialization work around MSBuild itself.

What Is the MSBuild Server?

Normally, a command such as:

Code
dotnet build

starts the .NET CLI, which invokes MSBuild and performs several stages before the project can be built.

A simplified flow looks like this:

Code
dotnet build
      |
      v
.NET CLI starts
      |
      v
MSBuild starts
      |
      v
Project evaluation
      |
      v
SDK / targets / tasks are loaded
      |
      v
Compilation and other build work
      |
      v
Build completes

With MSBuild Server enabled, the process can be reused:

Code
First dotnet build
      |
      v
Start MSBuild Server
      |
      v
Load MSBuild context
      |
      v
Build project
      |
      v
Server remains available

Second dotnet build
      |
      v
Connect to existing server
      |
      v
Reuse cached context
      |
      v
Build project

The difference matters most when builds are frequent and the actual compilation work is relatively small.

Why Reusing MSBuild Helps

A build is more than compiling .cs files.

MSBuild has to evaluate project files, resolve SDK information, load targets and tasks, establish the build environment, and coordinate project execution.

Consider a developer working on a solution with several projects:

Code
MyApplication.sln
 ├── Web
 ├── Application
 ├── Domain
 ├── Infrastructure
 ├── Worker
 └── Tests

A developer may repeatedly run:

Code
dotnet build
dotnet test
dotnet build
dotnet test

The source code changes may be small, but each command still needs to initialize the build infrastructure.

The MSBuild Server keeps part of that infrastructure alive between compatible CLI invocations.

This makes the feature particularly relevant to interactive development workflows.

MSBuild Server and Visual Studio Are Different

One important detail is that MSBuild Server is primarily a .NET CLI optimization.

Visual Studio already hosts MSBuild and keeps relevant build state alive while the IDE is running. Therefore, enabling MSBuild Server does not provide the same benefit to normal Visual Studio builds.

The feature is mainly relevant to commands such as:

Code
dotnet build
dotnet test
dotnet msbuild

This distinction prevents a common misunderstanding: installing or enabling MSBuild Server is not a general replacement for Visual Studio's existing build infrastructure.

MSBuild Server Is Not the Same as the C# Compiler Server

.NET developers may already know about compiler servers such as Roslyn's compiler processes.

These solve a different problem.

Component

Main purpose

MSBuild Server

Reuses MSBuild process and build context

Compiler server

Reuses compiler infrastructure

Incremental build

Avoids rebuilding unchanged work

Parallel build

Builds independent projects concurrently

Visual Studio

Hosts and manages build infrastructure during IDE sessions

These mechanisms can work together.

For example, a build can avoid unchanged projects through incremental build logic while also reusing MSBuild infrastructure through the server.

Enabling MSBuild Server

With the current .NET SDK behavior, MSBuild Server is enabled by default for supported MSBuild-based .NET CLI commands.

For developers using an SDK where it is not enabled by default, the feature can be enabled through the CLI environment configuration.

For example:

Code
DOTNET_CLI_USE_MSBUILD_SERVER=true

On Windows PowerShell:

PowerShell
$env:DOTNET_CLI_USE_MSBUILD_SERVER="true"

The exact environment behavior depends on the SDK version being used, so teams should verify the setting against their installed SDK rather than copying an environment configuration blindly.

Testing the Server During Local Development

The easiest way to understand the effect is to run the same build repeatedly.

For example:

Code
dotnet build
dotnet build
dotnet build

The first invocation can start and initialize the server. Subsequent compatible builds can connect to the existing process.

You can also use diagnostic verbosity:

Code
dotnet build -v:diag

Diagnostic output can help determine whether the server was started, reused, or bypassed.

This is useful when a developer expects the server to be active but sees no improvement.

The Server Does Not Stay Alive Forever

MSBuild Server is not intended to remain running indefinitely.

After completing a build, the server can remain available for another compatible invocation. If it remains idle for long enough, it shuts down.

This behavior is intentional.

A persistent process provides value when builds happen repeatedly, but keeping every developer's build infrastructure alive forever would waste memory and other system resources.

For that reason, MSBuild Server is most useful during active development sessions rather than as a permanent background service.

Disabling MSBuild Server

There are situations where disabling the server is useful.

A common option is:

Code
dotnet build --disable-build-servers

This tells the .NET CLI to ignore persistent build servers.

You can also shut down currently running build servers:

Code
dotnet build-server shutdown

This is useful when troubleshooting a build environment or when you suspect a persistent process is holding stale state.

MSBuild also supports disabling node reuse for a particular invocation:

Code
dotnet build -nr:false

Because MSBuild Server is a form of node reuse, this can prevent the normal persistent-server behavior.

When Should You Disable It?

You normally do not need to disable MSBuild Server during everyday development.

However, there are practical troubleshooting cases where it makes sense.

For example, if a build behaves differently after changing SDKs, targets, tasks, or build environment variables, comparing these two commands can be useful:

Code
dotnet build

and:

Code
dotnet build --disable-build-servers

If the second command behaves correctly while the normal command does not, persistent build state becomes an important area to investigate.

This does not automatically mean the server is the root cause. It simply gives you a controlled comparison.

MSBuild Server in CI/CD

MSBuild Server is primarily valuable for developer machines.

Traditional CI jobs often create a clean build environment, run the build, and dispose of that environment afterward. In that model, there may be little opportunity for a persistent server to provide value across separate jobs.

For example:

Code
CI Job
  |
  +-- Create runner
  |
  +-- Restore
  |
  +-- Build
  |
  +-- Test
  |
  +-- Destroy runner

There is little benefit in maintaining a long-lived MSBuild process if the machine disappears immediately after the job.

The situation can be different for long-running self-hosted agents where multiple builds execute on the same machine. In those environments, the team should measure the behavior rather than assuming the server will improve every pipeline.

Common Mistakes

Assuming MSBuild Server Makes Compilation Faster

The server reduces repeated MSBuild startup and initialization work. It does not fundamentally change the performance of the C# compiler.

If compilation itself is the bottleneck, investigate compiler workload, project size, analyzers, source generators, parallelism, and incremental build behavior.

Expecting a Benefit From a Single Build

The main advantage comes from reuse.

A workflow like this:

Code
dotnet build

followed by no additional builds may not show much benefit.

A developer repeatedly running builds during a coding session is a much better use case.

Confusing Server Reuse With Incremental Builds

These are different optimizations.

Incremental builds reduce the amount of work that needs to be performed.

MSBuild Server reduces repeated process startup and initialization overhead.

You generally want both.

Assuming Visual Studio Needs It

Visual Studio already hosts MSBuild and manages its build process internally. The CLI server is primarily intended for command-line build workflows.

Ignoring Memory Usage

A persistent process consumes memory while it remains active.

The server is designed to shut down after inactivity, but developers working on very large solutions should still consider overall system resource usage when troubleshooting build performance.

Best Practices

Measure Before Changing Build Configuration

Start with a repeatable workflow.

For example:

Code
dotnet build
dotnet build
dotnet build

Then compare the same workflow with persistent build servers disabled:

Code
dotnet build --disable-build-servers
dotnet build --disable-build-servers
dotnet build --disable-build-servers

The comparison should be made on the same machine and project state.

Keep Incremental Builds Healthy

MSBuild Server works alongside incremental builds. If every small source change causes unnecessary projects to rebuild, fixing that problem will usually have a larger effect than focusing only on MSBuild startup time.

Look for unnecessary project dependencies, custom targets that always execute, generated files that invalidate builds, and poorly configured inputs and outputs.

Use Diagnostic Logging for Unexpected Behavior

When the build server appears not to be used:

Code
dotnet build -v:diag

can provide useful information about the build lifecycle.

Binary logs are also valuable when diagnosing complex MSBuild behavior:

Code
dotnet build -bl

Treat Local and CI Builds Differently

Do not copy every local development optimization into CI without measuring it.

Local development often involves many consecutive builds. CI may use short-lived runners where process reuse provides little value.

Advantages

  • Reduces repeated MSBuild process startup overhead.

  • Reuses cached MSBuild context between compatible builds.

  • Helps interactive CLI development workflows.

  • Works with the existing dotnet build workflow.

  • Can complement incremental and parallel builds.

  • Requires little application-level code or project-file modification.

Disadvantages

  • Does not make the compiler itself inherently faster.

  • Provides limited value for isolated one-off builds.

  • Can complicate troubleshooting when persistent state is suspected.

  • Consumes memory while the server remains active.

  • Provides less benefit in short-lived CI environments.

  • Behavior can vary when command-line options prevent server reuse.

Troubleshooting Checklist

If a developer expects MSBuild Server to improve build performance but sees no difference, check the following:

  1. Confirm the command is running through the .NET CLI.

  2. Check that the installed SDK supports the server behavior you expect.

  3. Run multiple consecutive builds instead of measuring only the first build.

  4. Use diagnostic verbosity to inspect server lifecycle information.

  5. Check whether node reuse or command-line options disable the server.

  6. Compare against --disable-build-servers.

  7. Check whether compilation or project evaluation is actually the dominant cost.

  8. Inspect custom MSBuild targets and analyzers if builds remain slow.

A Practical Development Workflow

For a developer working primarily from the command line, a useful workflow is straightforward:

Code
dotnet restore
dotnet build
dotnet test
dotnet build

During the first build, the MSBuild Server may need to initialize.

Later commands can reuse the server when their invocation is compatible.

If something appears stale or behaves unexpectedly, reset the persistent build infrastructure:

Code
dotnet build-server shutdown

Then run the build again.

This gives developers a simple recovery mechanism without modifying the project.

Summary

The new MSBuild Server improves an important part of the .NET CLI build experience: repeated MSBuild startup and initialization.

Instead of treating every CLI build as an entirely new MSBuild process, the server can remain available and preserve useful context for subsequent builds.

The feature is most useful during active local development, especially when developers repeatedly build and test large solutions. It works alongside incremental builds, parallel execution, and compiler caching rather than replacing them.

For most developers, there is no application code to change and little configuration to maintain. The practical approach is to keep the default behavior, measure repeated builds, and use diagnostic tools when performance or stale-state problems appear.

The biggest lesson is simple: if your builds are slow because there is too much work, optimize the build graph. If they are slow because the build infrastructure keeps starting from scratch, MSBuild Server is designed to reduce that repeated overhead.