Optimize the Visual Studio experience on Microsoft Dev Box

With Visual Studio 17.8, you can try precaching of Visual Studio solutions for Microsoft Dev Box. When loading projects, Visual Studio indexes files and generates metadata to enable the full suite of IDE capabilities. As a result, Visual Studio can sometimes take a considerable amount of time when loading large projects for the first time. With Visual Studio caches on dev box, you can now pregenerate this startup data and make it available to Visual Studio as part of your customized dev box image. This means that when you create a dev box from a custom image including Visual Studio caches, you can log onto a Microsoft Dev Box and start working on your project immediately.

Benefits of precaching your Visual Studio solution on a dev box image include:

  • You can reduce the time it takes to load your solution for the first time.
  • You can quickly access and use key IDE features like Find In Files and Intellisense in Visual Studio.
  • You can improve the Git performance on large repositories.

Note

Performance gains in startup time from precaching of your Visual Studio solution will vary depending on the complexity of your solution.

Prerequisites

To leverage precaching of your source code and Visual Studio IDE customizations on Microsoft Dev Box, you need to meet the following requirements:

Enable Visual Studio caches in dev box images

You can generate caches for your Visual Studio solution as part of an automated pipeline that builds custom dev box images. To enable Visual Studio caches in your dev box image:

  • Within the Azure Resource Manager template, add a customized step to clone the source repository of your project into a nonuser specific location on the VM.

  • With the project source located on disk you can now run the PopulateSolutionCache feature to generate the project caches. To do this, add the following PowerShell command to your template's customized steps:

    # Add a command line flag to the Visual Studio devenv
    devenv SolutionName /PopulateSolutionCache /LocalCache /Build [SolnConfigName [/Project ProjName [/ProjectConfig ProjConfigName]] [/Out OutputFilename]]
    

    This command will open your solution, execute a build, and generate the caches for the specified solution. The generated caches will then be included in the custom image and available to dev box users once posted to a connected Azure Compute Gallery. You can then create a new dev box based off this image.

    The /Build flag is optional, but without it some caches that require a build to have completed won't be available. For more information on the build command, see Build command-line reference.

When a dev box user opens the solution on a dev box based off the customized image, Visual Studio will read the already generated caches and skip the cache generation altogether.

Enable Git commit-graph optimizations in dev box images

Beyond the standalone commit-graph feature, you can also enable commit-graph optimizations as part of an automated pipeline that generates custom dev box images.

You can enable Git commit-graph optimizations in your dev box image if you meet the following requirements:

To enable the commit-graph optimization, execute the following git commands from your Git repository’s location as part of your custom image build process:

# Enables the Git repo to use the commit-graph file, if the file is present 
git config --local core.commitGraph true

# Update the Git repository’s commit-graph file to contain all reachable commits
git commit-graph write --reachable

The generated caches will then be included in the custom image and available to dev box users once posted to a connected Azure Compute Gallery.

Next steps

Get started with Visual Studio precaching in Microsoft Dev Box:

We’d love to hear your feedback, input, and suggestions on Visual Studio precaching in Microsoft Dev Box via the Developer Community.