Cache NativeAOT Visual Studio tool discovery#129316
Open
MichalStrehovsky wants to merge 1 commit into
Open
Conversation
Run vswhere during Windows NativeAOT setup to validate the selected Visual Studio installation and reuse cached vcvarsall output when the installation path and version match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Windows NativeAOT build integration to discover Visual Studio toolchains via vswhere.exe and cache the derived vcvarsall.bat output (tool directory + LIB paths) in $(NativeIntermediateOutputPath) so subsequent builds can reuse it.
Changes:
- Replace the
findvcvarsall.batinvocation with in-targetvswhere.execalls to locate the VS installation path/version and compute the appropriatevcvarsallenvironment. - Add a per-architecture cache file (
findvcvarsall.$(_targetArchitecture).txt) to reuse priorvcvarsalloutput when the VS path/version match. - Remove the now-unused
findvcvarsall.batscript.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets | Implements vswhere-based VS discovery and a cache file to reuse vcvarsall output. |
| src/coreclr/nativeaot/BuildIntegration/findvcvarsall.bat | Deleted (logic is now embedded in the .targets file). |
Comment on lines
+179
to
+186
| <PropertyGroup Condition="'$(IlcUseEnvironmentalTools)' != 'true'"> | ||
| <_FindVCVarsallCachedVSInstallationPath Condition="'@(_FindVCVarsallCachedVSInstallationPathLine)' != ''">@(_FindVCVarsallCachedVSInstallationPathLine->'%(Value)', '')</_FindVCVarsallCachedVSInstallationPath> | ||
| <_FindVCVarsallCachedVSInstallationVersion Condition="'@(_FindVCVarsallCachedVSInstallationVersionLine)' != ''">@(_FindVCVarsallCachedVSInstallationVersionLine->'%(Value)', '')</_FindVCVarsallCachedVSInstallationVersion> | ||
| <_FindVCVarsallCachedOutput Condition="'@(_FindVCVarsallCachedOutputLine)' != ''">@(_FindVCVarsallCachedOutputLine->'%(Value)', '')</_FindVCVarsallCachedOutput> | ||
| <_FindVCVarsallCacheValid Condition="'$(_FindVCVarsallCachedVSInstallationPath)' == '$(_FindVCVarsallVSInstallationPath)' and '$(_FindVCVarsallCachedVSInstallationVersion)' == '$(_FindVCVarsallVSInstallationVersion)' and '$(_FindVCVarsallCachedOutput)' != ''">true</_FindVCVarsallCacheValid> | ||
| <_FindVCVarsallOutput Condition="'$(_FindVCVarsallCacheValid)' == 'true'">$(_FindVCVarsallCachedOutput)</_FindVCVarsallOutput> | ||
| <_VCVarsAllFound Condition="'$(_FindVCVarsallCacheValid)' == 'true'">0</_VCVarsAllFound> | ||
| </PropertyGroup> |
Comment on lines
+155
to
+160
| <Exec Condition="'$(IlcUseEnvironmentalTools)' != 'true'" | ||
| Command=""$(_FindVCVarsallVSWherePath)" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.$(_FindVCVarsallToolsSuffix) -property installationVersion" | ||
| ConsoleToMSBuild="true" StandardOutputImportance="Low"> | ||
| <Output TaskParameter="ConsoleOutput" PropertyName="_FindVCVarsallVSInstallationVersion" /> | ||
| <Output TaskParameter="ExitCode" PropertyName="_FindVCVarsallVSInstallationVersionExitCode" /> | ||
| </Exec> |
This was referenced Jun 12, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #129265
Run vswhere during Windows NativeAOT setup to validate the selected Visual Studio installation and reuse cached vcvarsall output when the installation path and version match.