WindowsSdk: Fix finding the _Instances directory when it's not in the default location #19926
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.
Information about installed MSVC instances are stored in
state.json
files within aPackages/_Instances
directory. The default location for this is%PROGRAMDATA%\Microsoft\VisualStudio\Packages\_Instances
. However, it is possible for the Packages directory to be put somewhere else. In that case, the registry valueHKLM\SOFTWARE\Microsoft\VisualStudio\Setup\CachePath
is set and contains the path to the Packages directory.Previously, WindowsSdk did not check that registry value. After this commit, the registry value
HKLM\SOFTWARE\Microsoft\VisualStudio\Setup\CachePath
is checked first, which matches what ISetupEnumInstances does (according to a Procmon log).Some more context: https://ziggit.dev/t/how-to-correctly-compile-static-libraries-on-windows/4232/23
Also fixes
KEY_WOW64_32KEY
being set whenever opening a registry key. This was causingHKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\Setup
to be attempted to be opened instead ofHKLM\SOFTWARE\Microsoft\VisualStudio\Setup
Confirmed to fix the motivating use case: https://ziggit.dev/t/how-to-correctly-compile-static-libraries-on-windows/4232/34