Large C# and VB solutions load significantly faster in 15.5 update

Viktor

November 20th, 2017

On average, 50 percent of all solutions opened by Visual Studio users open in ten seconds or less. However, large solutions can take longer to load because there are a lot of projects that Visual Studio needs to process.

Over the last six months, we looked at ways to make solution load much faster, even for large solutions. We are happy to share that with update 15.5, Visual Studio 2017 loads C# and Visual Basic projects twice as fast as before. (C++ solution load was optimized earlier in Visual Studio 2017, as described here.)

This video compares loading the Orchard Content Management System solution before and after optimization. Check out the video, try Visual Studio 2017 15.5 for your large solution, and tell us how much faster it loads for you! You can reach us at vssolutionload at Microsoft.

Design Time Build

Loading a solution in Visual Studio is much more involved than just parsing XML project files and rendering the Solution Explorer tree. To let you be productive right away, Visual Studio enables various IDE features at solution load. These features require a deep understanding of projects, project files, and dependencies. To calculate this information, Visual Studio runs a design-time build during solution load. This can be an expensive operation. Additionally, inefficiencies in customized project files and build targets can make it worse. In some cases, developers install certain Nuget packages that add even more operations to the design-time build.

What did we do?

Previously, Visual Studio loaded and built one project at a time on solution load. This design didn’t leverage the additional power of fast, multi-core machines. To reduce solution load time, Visual Studio now starts C# and Visual Basic design-time builds as early as possible. It also batches design-time build operations for all the projects in the solution and executes these build operations in parallel with other solution load operations.

We also improved references analysis. Most C# and Visual Basic projects have references to assemblies. To enable you to work with project references, Visual Studio needs to read information about these assemblies, such as the assembly’s version and description. These simple reads can add many seconds during a large solution load, because solutions often have thousands of assembly references across all their projects. Since many projects often have the same set of references, we further reduced solution load time by adding an in-memory “references” cache that is shared across all projects in a solution.

What can you do?

While much of solution load is automatic, parts of it are in your control. The Project System Tools extension can help you identify projects and targets that are slowing down design-time build during solution load.

To do this, install the extension and then delete the hidden .vs subfolder in your solution folder to clear the design-time build cache. Then open the Build Logging window, start recording, and open a solution. The window will show a list of targets and design time build time for each project. Identify slow projects and inspect their targets, then edit your project files to remove unnecessary targets from the design-time build. You can find more design time build optimization techniques here.

Hard drive type matters!

And here is another trick to make solution load even faster. Visual Studio telemetry shows that machines with an SSD storage load solutions 2-3 times faster than a regular hard drive. As such, we strongly recommend considering an upgrade to SSD if you are using a regular hard drive. While ideally Windows, Visual Studio, and your solution would all be contained on an SSD for the maximum impact, having Windows installed on SSD will have a huge impact on your solution load.

Share your feedback

We hope that you will enjoy faster solution load time in Visual Studio 15.5 update. Please try it on your solutions and let us know what you think.