with one click
deploy-msbuild-to-vs
Deploy locally-built MSBuild binaries into a Visual Studio installation for testing and debugging. Use when you need VS itself to use your local MSBuild changes, or when debugging MSBuild as invoked by VS.
Menu
Deploy locally-built MSBuild binaries into a Visual Studio installation for testing and debugging. Use when you need VS itself to use your local MSBuild changes, or when debugging MSBuild as invoked by VS.
Orchestrate an MSBuild release: create the tracking issue, branch, configure DARC channels and subscriptions, bump version in main, final-brand the release branch, insert into VS, and publish post-GA. Covers the full monthly release lifecycle aligned with VS shipping cadence.
Guides struct-based COM interop in MSBuild using CsWin32 patterns. Consult when working with ComScope<T>, ComClassFactory, IComIID, IID.Get<T>(), delegate* unmanaged vtables, CoCreateInstance, or manually defining COM interfaces not in Win32 metadata (e.g. WMI IWbemLocator, IWbemServices).
Guides CsWin32 P/Invoke interop in MSBuild. Consult when working with the PInvoke class, Windows.Win32 namespaces, FEATURE_WINDOWSINTEROP, HANDLE/HMODULE/HRESULT types, BufferScope<T>, replacing [DllImport] with CsWin32, or conditioning Windows-only code for source builds.
Guide for running MSBuild unit tests efficiently. Use when running, scoping, filtering, or speeding up unit tests in this repository, or when finalizing a change with a heavier validation pass. Covers xUnit v3 + Microsoft.Testing.Platform (MTP) specifics and which `dotnet test` flags do and don't apply.
GitHub issue and project-board management for the dotnet/msbuild repo. Use when asked to file/triage/update issues, post comments, amend issue bodies, move sprints, bulk-update project board fields, or audit items by sprint/status/assignee.
Guides assessment of backward compatibility for MSBuild changes. Consult when modifying behavior, adding warnings or errors, changing defaults, altering target ordering, removing or deprecating features, deciding whether a change needs a ChangeWave, reviewing blast radius of behavioral changes, or when a PR introduces user-visible output differences.
| name | deploy-msbuild-to-vs |
| description | Deploy locally-built MSBuild binaries into a Visual Studio installation for testing and debugging. Use when you need VS itself to use your local MSBuild changes, or when debugging MSBuild as invoked by VS. |
| argument-hint | Deploy local MSBuild to VS, patch VS with built MSBuild, debug MSBuild inside VS. |
This skill guides you through replacing Visual Studio's bundled MSBuild with your locally-built binaries, so that builds initiated from within VS use your changes. It also covers debugging MSBuild when invoked by VS and restoring the original state.
devenv.exe).If you only need command-line testing, prefer the bootstrap approach instead (see the use-bootstrap-msbuild skill). It is faster and does not risk breaking your VS installation.
Program Files).Run a full build from the repo root to produce the bootstrap output:
.\build.cmd
By default this builds Debug configuration. If you want Release:
.\build.cmd /p:Configuration=Release
The build creates bootstrap binaries under artifacts\bin\MSBuild.Bootstrap\{configuration}\.
Find the MSBuild Bin folder inside your VS installation. The path depends on your VS version and edition.
⚠ Important: If you have multiple VS versions or editions installed side-by-side, make sure you identify the correct installation path for the instance you want to patch. Confirm the path exists before deploying.
The general pattern is:
C:\Program Files\Microsoft Visual Studio\{version}\{edition}\MSBuild\Current\Bin
Where {version} is the year (e.g. 2022, 2026) or a numeric version for previews (e.g. 18), and {edition} is Enterprise, Professional, Community, or Preview.
Example paths:
| VS Version | Edition | Typical Path |
|---|---|---|
| 2026 | Enterprise | C:\Program Files\Microsoft Visual Studio\2026\Enterprise\MSBuild\Current\Bin |
| 2022 | Community | C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin |
| Preview (v18) | Preview | C:\Program Files\Microsoft Visual Studio\18\Preview\MSBuild\Current\Bin |
The most reliable way to locate your VS installation is with vswhere:
# List all VS installations with their paths
& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -all -format table
# Get the MSBuild Bin path for the latest installation
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
"$vsPath\MSBuild\Current\Bin"
Alternatively, from a VS Developer Command Prompt:
where msbuild
Use the directory containing that MSBuild.exe.
From an administrator PowerShell, run:
.\scripts\Deploy-MSBuild.ps1 -destination "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin"
| Parameter | Default | Description |
|---|---|---|
-destination | (required) | The VS MSBuild Bin folder path |
-configuration | Debug | Must match the configuration used in build.cmd |
-runtime | Detect | Auto-detects Desktop vs Core from the path. Use Desktop for VS, Core for .NET SDK |
-binDirectory | artifacts\bin | Override if build output is elsewhere |
-makeBackup | $true | Creates a timestamped Backup-* folder before overwriting |
The script copies from artifacts\bin\MSBuild.Bootstrap\{configuration}\net472\:
Microsoft.Build.dll, Microsoft.Build.Framework.dll, Microsoft.Build.Tasks.Core.dll, Microsoft.Build.Utilities.Core.dll, Microsoft.NET.StringTools.dllMicrosoft.Common.targets, Microsoft.CSharp.targets, Microsoft.VisualBasic.targets, and many moreMSBuild.exe (x86 and amd64), MSBuildTaskHost.exeSystem.* assemblies needed for .NET FrameworkThe deploy script creates a backup folder at {destination}\Backup-{timestamp}\ by default.
To restore:
# Find the backup folder
Get-ChildItem "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Backup-*"
# Copy everything back
Copy-Item "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Backup-{timestamp}\*" `
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\" -Recurse -Force
Alternatively, run Visual Studio Installer → Modify → Repair to fully restore the original binaries.
⚠ CAUTION: If you overwrite MSBuild in Visual Studio and something goes wrong, VS itself may break (since VS uses MSBuild internally). Always keep the backup and know how to restore before deploying.
When MSBuild is invoked by VS (for real builds or design-time builds), you can attach a debugger using environment variables. Set these before launching VS:
$env:MSBuildDebugBuildManagerOnStart = "1" # 1 = Debugger.Launch(), 2 = wait for attach
$env:MSBuildDebugProcessName = "devenv" # Only trigger in the VS process
devenv.exe
This breaks into BuildManager.BeginBuild, which is where VS calls into MSBuild's API.
$env:MSBUILDDEBUGONSTART = "1" # 1 = Launch debugger, 2 = Wait for attach, 3 = Main process only
devenv.exe
VS heavily filters MSBuild events and suppresses them entirely during design-time builds. To capture everything:
$env:MSBuildDebugEngine = "1"
$env:MSBUILDDEBUGPATH = "C:\temp\MSBuild_Logs" # Optional: override log output directory
$env:MSBuildDebugProcessName = "devenv" # Optional: only log from VS
devenv.exe
This injects a binary log at BuildManager.BeginBuild, capturing full logs for both real and design-time builds. Logs are saved to MSBuild_Logs\ under the current directory (or MSBUILDDEBUGPATH if set).
To patch a .NET SDK installation rather than VS:
.\scripts\Deploy-MSBuild.ps1 -destination "C:\Program Files\dotnet\sdk\10.0.100" -runtime Core
The script auto-detects SDK paths (containing dotnet and sdk), but you can force it with -runtime Core.
If you cannot build MSBuild on the target machine:
Build and deploy to an empty folder:
.\scripts\Deploy-MSBuild.ps1 -destination "C:\temp\msbuild-deploy"
Copy the contents of that folder to the target machine's VS MSBuild Bin folder.
Make a manual backup of the target machine's files first.
| Problem | Solution |
|---|---|
| Access denied when deploying | Run PowerShell as Administrator |
| VS won't start after deploy | Restore from Backup-* folder or run VS Installer Repair |
| Changes not reflected in VS | Close all VS instances and reopen; kill lingering MSBuild.exe processes |
| Configuration mismatch | Ensure -configuration matches what you passed to build.cmd |
| Build errors in MSBuild repo | Run .\build.cmd from a clean state; see Something's wrong in my build |
| Step | Command |
|---|---|
| Build MSBuild | .\build.cmd |
| Deploy to VS (admin) | .\scripts\Deploy-MSBuild.ps1 -destination "{VS MSBuild Bin path}" |
| Deploy Release build | .\scripts\Deploy-MSBuild.ps1 -destination "{path}" -configuration Release |
| Debug MSBuild in VS | Set $env:MSBuildDebugBuildManagerOnStart = "1" then launch devenv.exe |
| Capture VS binlogs | Set $env:MSBuildDebugEngine = "1" then launch devenv.exe |
| Restore original | Copy back from Backup-* folder or run VS Installer Repair |