Skip to content

Commit 48f948d

Browse files
Merge pull request #244031 from anandmeg/vs-devbox2
Add new doc on generating vs caches in Dev Box
2 parents 81facea + cfebf4b commit 48f948d

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: Configure Visual Studio caches for your dev box image
3+
titleSuffix: Microsoft Dev Box
4+
description: Learn how to generate Visual Studio caches for your customized Dev Box image.
5+
services: dev-box
6+
ms.service: dev-box
7+
author: RoseHJM
8+
ms.author: rosemalcolm
9+
ms.date: 07/17/2023
10+
ms.topic: how-to
11+
---
12+
13+
# Optimize the Visual Studio experience on Microsoft Dev Box
14+
15+
> [!IMPORTANT]
16+
> Visual Studio precaching for Microsoft Dev Box is currently in public preview. This information relates to a feature that may be substantially modified before it's released. Microsoft makes no warranties, expressed or implied, with respect to the information provided here.
17+
18+
With [Visual Studio 17.7 Preview 3](https://visualstudio.microsoft.com/vs/preview/), 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](/visualstudio/get-started/visual-studio-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.
19+
20+
Benefits of precaching your Visual Studio solution on a dev box image include:
21+
- You can reduce the time it takes to load your solution for the first time.
22+
- You can quickly access and use key IDE features like Find In Files and IntelliSense in Visual Studio.
23+
- You can improve the Git performance on large repositories.
24+
25+
> [!NOTE]
26+
> Performance gains in startup time from precaching of your Visual Studio solution will vary depending on the complexity of your solution.
27+
28+
## Prerequisites
29+
30+
To leverage precaching of your source code and Visual Studio IDE customizations on Microsoft Dev Box, you need to meet the following requirements:
31+
32+
- Create a dev center and configure the Microsoft Dev Box service. If you don't have one available, follow the steps in [Quickstart: Configure Microsoft Dev Box](quickstart-configure-dev-box-service.md) to create a dev center and configure a dev box.
33+
- [Create a custom VM image for dev box](how-to-customize-devbox-azure-image-builder.md) that includes your source code and pregenerated caches.
34+
35+
This article guides you through the creation of an Azure Resource Manager template. In the following sections, you'll modify that template to include processes to [generate the Visual Studio solution cache](#enable-caches-in-dev-box-images) and further improve Visual Studio performance by [preparing the git commit graph](#enable-git-commit-graph-optimizations) for your project.
36+
37+
You can then use the resulting image to [create new dev boxes](quickstart-configure-dev-box-service.md#3-create-a-dev-box-definition) for your team.
38+
39+
## Enable caches in dev box images
40+
41+
You can generate caches for your Visual Studio solution as part of an automated pipeline that builds custom dev box images. To do so, you must meet the following requirements:
42+
43+
* Within the [Azure Resource Manager template](../azure-resource-manager/templates/overview.md), add a customized step to clone the source repository of your project into a nonuser specific location on the VM.
44+
* 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:
45+
46+
```shell
47+
# Add a command line flag to the Visual Studio devenv
48+
devenv SolutionName /PopulateSolutionCache /LocalCache /Build [SolnConfigName [/Project ProjName [/ProjectConfig ProjConfigName]] [/Out OutputFilename]]
49+
```
50+
51+
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](how-to-customize-devbox-azure-image-builder.md) and available to dev box users once [posted to a connected Azure Compute Gallery](../virtual-machines/shared-image-galleries.md). You can then [create a new dev box](quickstart-configure-dev-box-service.md#3-create-a-dev-box-definition) based off this image.
52+
53+
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](/visualstudio/ide/reference/build-devenv-exe).
54+
55+
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.
56+
57+
## Enable Git commit-graph optimizations
58+
59+
Beyond the [standalone commit-graph feature that was made available with Visual Studio 17.2 Preview 3](https://devblogs.microsoft.com/visualstudio/supercharge-your-git-experience-in-vs/), you can also enable commit-graph optimizations as part of an automated pipeline that generates custom dev box images. To do so, you must meet the following requirements:
60+
61+
* You're using a [Microsoft Dev Box](overview-what-is-microsoft-dev-box.md) as your development workstation.
62+
* The source code for your project is saved in a non-user specific location to be included in the image.
63+
* You can [create a custom dev box image](how-to-customize-devbox-azure-image-builder.md) that includes the Git source code repository for your project.
64+
* You're using [Visual Studio 17.7 Preview 3 or higher](https://visualstudio.microsoft.com/vs/preview/).
65+
66+
To enable this optimization, execute the following `git` commands from your Git repository’s location as part of your image build process:
67+
68+
```bash
69+
# Enables the Git repo to use the commit-graph file, if the file is present
70+
git config --local core.commitGraph true
71+
72+
# Update the Git repository’s commit-graph file to contain all reachable commits
73+
git commit-graph write --reachable
74+
```
75+
76+
The generated caches will then be included in the [custom image](how-to-customize-devbox-azure-image-builder.md) and available to dev box users once [posted to a connected Azure Compute Gallery](../virtual-machines/shared-image-galleries.md).
77+
78+
## Next steps
79+
80+
Get started with Visual Studio precaching in Microsoft Dev Box:
81+
82+
- [Download and install Visual Studio 17.7 Preview 3 or later](https://visualstudio.microsoft.com/vs/preview/).
83+
84+
We’d love to hear your feedback, input, and suggestions on Visual Studio precaching in Microsoft Dev Box via the [Developer Community](https://visualstudio.microsoft.com/vs/preview/).

articles/dev-box/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ items:
5555
href: how-to-install-dev-box-cli.md
5656
- name: Provision a Custom Image with Azure Image Builder
5757
href: how-to-customize-devbox-azure-image-builder.md
58+
- name: Configure Visual Studio caches
59+
href: how-to-generate-visual-studio-caches.md
5860
- name: Manage a dev box through developer portal
5961
href: how-to-create-dev-boxes-developer-portal.md
6062
- name: How to configure Dev Box Hibernation

0 commit comments

Comments
 (0)