Skip to content

Cache NativeAOT Visual Studio tool discovery#129316

Open
MichalStrehovsky wants to merge 1 commit into
dotnet:mainfrom
MichalStrehovsky:nativeaot-vcvarsall-cache
Open

Cache NativeAOT Visual Studio tool discovery#129316
MichalStrehovsky wants to merge 1 commit into
dotnet:mainfrom
MichalStrehovsky:nativeaot-vcvarsall-cache

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

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.

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>
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.bat invocation with in-target vswhere.exe calls to locate the VS installation path/version and compute the appropriate vcvarsall environment.
  • Add a per-architecture cache file (findvcvarsall.$(_targetArchitecture).txt) to reuse prior vcvarsall output when the VS path/version match.
  • Remove the now-unused findvcvarsall.bat script.

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="&quot;$(_FindVCVarsallVSWherePath)&quot; -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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SetupOSSPecificProps target is not incremental

2 participants