Accelerate your .NET build with Visual Studio 2022

Accelerate your .NET build with Visual Studio 2022

A little more than three months ago, Microsoft integrated a new functionality into Visual Studio 2022: Build Acceleration.

This mechanism, which can be optionally activated, apparently ensures that build times for .NET projects can be reduced by up to 80%. This is, of course, an announcement that I wanted to take a closer look at.

SDK Changes

This feature does not have to be activated in Visual Studio itself; it is activated via the SDK settings in the project file (*.csproj). In order not to define this in all projects individually, you can also store this option in the Directory.Build.props file, so that all projects of the solution receive this setting.

<Project>
    <PropertyGroup>
        <AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
    </PropertyGroup>
</Project>

Results

As a test for the speed changes, I am taking a current customer project that has about 130 projects in the solution. For this test, I have made a change to a central project so that not only a project but the reference tree has to be rebuilt.

Build without Acceleration

Without the Acceleration, all projects will be rebuilt.

========== Build: 128 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 18:26 and took 16,637 seconds ==========

Build with Acceleration

With Acceleration, only the affected project is built and all other projects benefit from the new performance mechanism.

========== Build: 1 succeeded, 0 failed, 127 up-to-date, 0 skipped ==========
========== Build completed at 18:29 and took 01,182 seconds ==========
Visual Studio accelerated 20 project(s), copying 41 file(s). See https://aka.ms/vs-build-acceleration.

Conclusion

The speed benefits from the new Visual Studio Build Acceleration are enormous - and another reason to stay with Visual Studio. This feature makes our team much more productive over time.

Try it out!