10 Tips to Improve Visual Studio Build Performance (2024)

Introduction

With increasing business demands, ASP.NET projects become more and more complex and 'large' resulting in higher project build and load times. While buying a faster processor, better hardware and increasing RAM sizes are always options to consider to improve performance. Secondly, making architectural changes in ASP.NET project like separating project logically, minimizing number of assemblies and creating separate solutions can also be considered as long term strategies for the same. However these are not preferred approaches, if one wants to see the improvement instantly. To overcome such limitations, there are number of tips which can be used to quickly improve the application build times and thereby improving development productivity many folds.

Background

Personally, I felt that when an application starts taking more than a minute to build, then it's time to sit down and think about making appropriate adjustments so that the application build time remains in acceptable limits. Broadly, the improvement factors can be categorized as below:

  1. Optimizing Visual Studio settings
  2. Overall Project architecture changes
  3. Use of improved hardware like processor, hard disk, RAM, etc.

For the purpose of this tip, we will mainly focus on #1, Optimizing Visual Studio settings, while touching briefly on #2, Project architectural changes.

Improvement Tips

I will start with making configuration changes in Visual Studio first and then will touch some project level settings followed by easy architectural changes and finally with some other options which are worth mentioning.

1. Use Parallel Builds

This is a magical setting which builds project in your solutions in parallel. Although, there could be project dependencies set in your project which will allow some project to build in particular order, still this setting would automatically deduce the parallelism among the projects during build. Set this value to an optimum level for your machine, e.g., for i7 processor which can execute up to 8 threads, you can set this setting to 8. This can be set in Visual Studio by Tools -> Options -> Projects and Solutions -> Build and Run. Refer below:

10 Tips to Improve Visual Studio Build Performance (1)

2. Only Build Startup and Dependencies on Run

While being on the "Build and Run" settings mentioned in the previous step, check "Only build startup and dependencies on Run". This could be especially helpful when there are a large number of projects and you would like to build and run startup project only without building all the projects in solution even if they are not dependent and further those unrelated project could include pre or post build tasks. Refer Build the currently selected project.

10 Tips to Improve Visual Studio Build Performance (2)

3. Set Build Verbosity

You can set the build verbosity based on your choice. However, updating this setting would also decrease the build overhead and reduces the build time. Again referring to the same screenshot provided in tip #1, set the MSBuild project build output verbosity to "Minimal". This will show minimum build detail during build in build output window. You can even set it to quiet if you need not see output or occasionally you may set it to detailed or even diagnostics to troubleshoot issues in build depending upon the requirement.

10 Tips to Improve Visual Studio Build Performance (3)

4. PreCompiled MVC Razor Views

By default, MVC views are compiled at runtime. We can build MVC views during MVC project build, using MVCBuildViews as true. However, MVCBuildViews comes with performance penalty so pre-compiling MVC views is the most preferred approach to manage MVC view effectively. You can refer to Precompile your MVC Razor views using Razor Generator to try it yourself.

5. Build Required Projects Only

There could be certain projects in your solution such as setup projects or projects which are not directly required to execute your start up project and can be excluded from build. It would be a good idea to exclude them from build. To exclude a project; on the menu bar, choose Build, Configuration Manager. In the Project contexts table, locate the project you want to exclude from the build. In the Build column for the project, clear the check box. Refer to the screenshot below:

10 Tips to Improve Visual Studio Build Performance (4)

6. Disable On-Access Virus scanner

This seems unrelated to Visual Studio build time, however on-access scanner scans file during file operations. Thus, it a good idea to investigate virus scanner and exclude development folders including .NET framework temporary files and folders.

7. Mystical Project Settings

There are some project settings which could also improve the build time of your Visual Studio project. It is not mandatory to use these properties as you may face inconsistency while setting these on your project; project may fail to build. However, these settings can have a huge impact on performance in the development system.

Set optimizeCompilations to true

XML

<Compilation debug="true" targetFramework="4.5" optimizeCompilations="true"/>

This flag is used to optimize ASP.NET compilation behavior and it caters to development environment. The setting detects minor updates done during development like update in a single method, addition of new method, rename or deletion of APIs, etc. which do not require full recompile. Thus, only a specific portion of project is compiled. Refer to A new flag to optimize ASP.NET compilation behavior for more details.

Set MVCBuildViews to false

As the name suggest, this setting is used for building MVC views in MVC based ASP.NET project. If you are not using pre-compiled views, then it is important to note that during development MVCBuildview takes around 80% of application build time in MVC application. This setting must be set to true if any MVC view is updated, added so that updates are reflected after compilation.

However, in case there are no changes in views, this setting can be set to false, which drastically reduces the build time. As a workaround, you can set MVCBuildView false for Debug configuration and true for Release configuration. In case view debugging is required, then this setting can optionally be set to true manually for the time being.

XML

<MvcBuildViews>false</MvcBuildViews>

To set its value, open your MVC project's csproj file in Text editor of your choice and manually edit the property in YourProjecct.csproj file.

Set Build Verbosity to Diagnostic

As per point #3, setting minimal build verbosity also has a impact on build. Setting Build output verbosity to diagnostic will let you know the details of individual operations being called during the build process. You can better a finer view and better control over minute activities during build and can fine tune based on your needs. Refer to the screen shot below to see a small snippet for the same.

10 Tips to Improve Visual Studio Build Performance (5)

Build Solution from Command Line

On a side note, if you build your solution from command line, you may see improved build time than using Visual Studio IDE as it does not have fancy UI and you can use a variety of Command Line options:

ms build overvaluations /verbosity:diagnostic

8. Set Common Output Directory

This technique can also be handy in making sure that there are no duplicate assemblies and content created during build. It can provide significant improvement on build time as same content will not be copied to local project folders. Refer to the screenshot below to set output directory for your build output.

10 Tips to Improve Visual Studio Build Performance (6)

An alternative technique, "Copy Local" to false can also be used to ensure that assemblies are not copied locally. However, this technique should be used diligently to ensure that it does not break the build itself. For more details, refer to Setting Copy Local to true.

10 Tips to Improve Visual Studio Build Performance (7)

Note: It is also worth mentioning to use RAM disk as output folder instead of hard drive. However, I have not tried this setting though.

9. Remove Unused Files and Dead Code from your Projects

Let us explore some other aspects on our code structure which can be improved for better performance. Firstly, remove any unused files from your projects; classes which are not used, files which are included in project but never referenced. Unnecessary code acts as a technical debt and bring down performance of almost every application.

Removing dead code can also be used to make your code size smaller and manageable. It should also be practiced for the long run if not for instant performance optimization. There are many Static Code Analysis tools available across many platforms to achieve clean code. You can also use Visual Studio built-in code analysis tool to diagnose code related issues.

10. Keep Optimum Number of Projects and Assemblies

This is rather an architectural concern, however it fits well to improve build time. More the number of projects and assemblies, more time it takes Compiler to perform the compilation. There is no such exact number which can be considered good, however based on the complexity of project and business requirement, the number of project and assemblies can vary. Keeping this to optimum level results in quick application build time and run time performance even though it is time-consuming and painful process to change the project architecture and setup.

Summary

There can be many aspects to improve build time of a particular application and it depends on many factors. The performance improvement cannot be done overnight and should be an on-going process. I have not provided exact benchmarking results as results can vary greatly depend on your projects.

I hope this gives you some ideas to improve your project compilation time and I know that there could be many other improvement points left which could be part of this tip.

If you have any such tips and tricks, please share!

Related Readings

History

First version of tips to improve Visual Studio Build performance.

Working as Technical lead in 3 Pillar Global. Having experience in ASP.NET, C#, Web API, WebServices, SQL Server and other Microsoft technologies.

10 Tips to Improve Visual Studio Build Performance (2024)
Top Articles
Amortisseur 80n Compatible Avec LG 4901er2003b pour Laver • EUR 12,57
Amortisseurs de vibrations pour raquettes de tennis Anti-vibrations • EUR 1,52
Syracuse Pets Craigslist
Old Bahama Bay Quad Folding Wagon
123Movies The Idol
Humidity Yesterday At My Location
Ups Open Today Near Me
Getwush Com
Best Bread for Gut Health
Craigslist Metal Roofing
Partyline Ads for Wednesday, September 11, 2024
35Mmx45Mm In Inches
Non Sequitur-exemples et définition de Non Sequitur
Keanu Reeves cements his place in action genre with ‘John Wick: Chapter 4’
Pritzker Sdn 2023
2887 Royce Road Varysburg Ny 14167
2021 Lexus IS 350 F SPORT for sale - Richardson, TX - craigslist
Sas Majors
Dive into Hearts and Adventure: Top 10 Lexi Heart Books to Experience
Devon Lannigan Obituary
Craigslist Apts Near Me
Insulated Dancing Insoles
Week 8 – Quarter 1 Matatag DLL Daily Lesson Logs | September 16 – 20, 2024 DLL
Funny Shooter Unblocked
Couches To Curios Photos
Ssbbw Coomer
Kobe Express Bayside Lakes Photos
Circuit Court Peoria Il
Lux Nails Mcmurray Pa
Clinical Pharmacology Quality Assurance (CPQA) Program: Models for Longitudinal Analysis of Antiretroviral (ARV) Proficiency Testing for International Laboratories
Storenet Walgreens At Home
Leccion 4 Lesson Test
Distance To Indianapolis
Was Lil Mosey In Ride Along
Demetrius Meach Nicole Zavala
Southeast Ia Craigslist
100K NOTES - [DEEPWOKEN - DEEP WOKEN - ROBLOX] | ID 217435304 | PlayerAuctions
Ben Rickert Net Worth
Surface Area Formulas (video lessons, examples, step-by-step solutions)
Natick Mall Directory Map
Aita For Telling My Niece Why I Kept A Distance
Grupos De Cp Telegram
What Happened To Daniel From Rebecca Zamolo
Sherlock - Streams, Episodenguide und News zur Serie
Norville Breast Center At Alamance Regional
2024 USAF & USSF Almanac: DAF Personnel | Air & Space Forces Magazine
Theresa Alone Gofundme
Sams Warehouse Jobs
Rida Asfahani Leaked Video
Sesame Street 4323
Craigslist Groton
The Emperor's New Groove | Rotten Tomatoes
Latest Posts
Article information

Author: Tish Haag

Last Updated:

Views: 6464

Rating: 4.7 / 5 (67 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Tish Haag

Birthday: 1999-11-18

Address: 30256 Tara Expressway, Kutchburgh, VT 92892-0078

Phone: +4215847628708

Job: Internal Consulting Engineer

Hobby: Roller skating, Roller skating, Kayaking, Flying, Graffiti, Ghost hunting, scrapbook

Introduction: My name is Tish Haag, I am a excited, delightful, curious, beautiful, agreeable, enchanting, fancy person who loves writing and wants to share my knowledge and understanding with you.