GeezerVison is showing github.com — Improve Visual Studio detection on Windows by gastaldi · Pull Request #228 · graalvm/setup-graalvm
Conversation
gastaldi
commented
Jul 7, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
- Use
vswhere.exe for dynamic Visual Studio detection, matching what GraalVM's own native-image does internally via WindowsBuildEnvironmentUtil
- Expand hardcoded paths to include all four VS editions (Enterprise, Professional, Community, BuildTools) as a fallback
- Preserve
VSINSTALLDIR env var as the highest-priority override
- Downgrade MSVC setup failure to a warning for JDK 17+, since
native-image performs its own VS detection in those versions
Detection order: VSINSTALLDIR → vswhere.exe → hardcoded paths.
Fixes #227.
Test plan
- Verify on GitHub-hosted runners (
windows-latest, windows-2022) — should work as before
- Verify on self-hosted runner with non-Enterprise VS edition (e.g. Community) — previously failed, should now succeed
- Verify
VSINSTALLDIR env var override still works
- Verify JDK 17+ with no VS installation produces a warning (not a failure)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Use `vswhere.exe` for dynamic Visual Studio detection, matching what
GraalVM's own `native-image` does internally. This correctly finds any
VS edition (Community, Professional, Build Tools, Enterprise) without
relying solely on hardcoded paths.
The detection order is:
1. `VSINSTALLDIR` env var (explicit user override)
2. `vswhere.exe` (dynamic detection)
3. Hardcoded paths (expanded to include all four editions)
Fixes graalvm#227.
gastaldi
changed the title
Use vswhere.exe to detect Visual Studio installations
Improve Visual Studio detection on Windows
Jul 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for the swift PR!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Native Image on JDK 17+ performs its own Visual Studio detection, so a
failure in setup-graalvm's MSVC environment setup should not be fatal
for these versions. For older JDKs, the error remains fatal.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Labels
OCA Verified
All contributors have signed the Oracle Contributor Agreement.
Milestone
No milestone
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.