Skip to content

Instantly share code, notes, and snippets.

@Acephalia
Created April 19, 2025 23:45
Show Gist options
  • Save Acephalia/7d32ad22a47ea3d9f8a1eb09feea3b9a to your computer and use it in GitHub Desktop.
Save Acephalia/7d32ad22a47ea3d9f8a1eb09feea3b9a to your computer and use it in GitHub Desktop.
Visual Studio Build Tools Installation Guide for Local AI Image Generation

Visual Studio Build Tools Installation Guide for AI Image Generation

Visual Studio Build Tools are essential for running ComfyUI, Stable Diffusion, Flux, Forge, and similar AI image generation tools locally on Windows. These tools provide the necessary C++ compiler and build environment required by many Python packages and CUDA-based applications. This guide will help you install the appropriate Visual Studio Build Tools to resolve common dependency issues.

1. Understanding VS Build Tools Versions

Visual Studio Build Tools come in several versions, with VS Build Tools 2022 being the latest as of April 2025. For most AI image generation tools, you'll need the C++ build tools component which provides the necessary compiler and libraries.

  • VS Build Tools 2022 – Latest version, recommended for newer applications
  • VS Build Tools 2019 – Still widely compatible with most AI tools
  • VS Build Tools 2015 – Only needed for specific older applications

2. Installing VS Build Tools with Winget (Recommended)

The easiest way to install VS Build Tools is using Windows Package Manager (winget). Open a command prompt and run:

winget install --id=Microsoft.VisualStudio.2022.BuildTools -e

For VS Build Tools 2019 (if needed for compatibility):

winget install --id=Microsoft.VisualStudio.2019.BuildTools -e

For VS Build Tools 2015 (rarely needed):

winget install --id=Microsoft.BuildTools2015 -e

3. Manual Installation of VS Build Tools

If winget is unavailable or you prefer manual installation:

  1. Download VS Build Tools from https://aka.ms/buildtools
  2. Run the installer
  3. When the Visual Studio Installer appears, select Desktop development with C++
  4. Click Install in the bottom right
  5. Wait for the installation to complete
  6. Restart your computer to ensure all changes take effect

4. Installing with Chocolatey

If you use Chocolatey package manager, you can install VS Build Tools with:

choco install visualstudio2022buildtools

To install Build Tools with C++ components (recommended for AI tools):

choco install visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"

5. Verifying Your Installation

After installation, you can verify that VS Build Tools are correctly installed by:

  1. Opening a new command prompt
  2. Running: cl.exe or msbuild -version
  3. If installed correctly, you should see version information rather than "command not found"

6. Troubleshooting Common Issues

If you encounter errors during installation:

  • Make sure you're running the installer as administrator
  • For older Windows versions, ensure you have the latest Windows updates
  • If installation fails, try running the Visual Studio Installer Repair tool
  • For 32-bit Windows systems, note that VS Build Tools 2022 is not officially supported

7. Adding VS Build Tools to PATH

Sometimes you'll need to add the VS Build Tools to your system PATH:

  1. Search for "Environment Variables" in Windows search
  2. Click "Edit the system environment variables"
  3. Click "Environment Variables" button
  4. Under "System variables", find and select "Path", then click "Edit"
  5. Add the path to your VS Build Tools installation, typically:
    C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin
  6. Click "OK" on all dialog boxes
  7. Restart any open command prompts or applications

8. Why VS Build Tools Are Needed

Many AI image generation tools rely on Python packages that require compilation of C++ code, particularly for CUDA optimisations. VS Build Tools provide the necessary compiler and build environment for these packages to install correctly. Without them, you'll often encounter errors during package installation with messages referring to missing C++ compilers or failed builds.

Remember to restart your computer after installing VS Build Tools to ensure all environment variables are properly set up. This is often missed but is an essential step to avoid unexpected errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment