Skip to content

Commit ac1794c

Browse files
committed
Always attempt MSVC environment setup on Windows
GraalVM native-image (released versions ≤21.0.x) uses a `20\d\d` regex to find Visual Studio installations, which does not match VS 2026's `\18\` directory. Previously, the action skipped MSVC setup for JDK 17+ assuming native-image handles it — but it can't find VS 2026. Now the action always runs vcvarsall.bat on Windows, putting cl.exe on PATH so native-image skips its own detection. For JDK 17+ and dev builds, failures are non-fatal (warning instead of error) since future native-image versions with vswhere support will handle it. Fixes #220
1 parent 809afe6 commit ac1794c

2 files changed

Lines changed: 71 additions & 58 deletions

File tree

dist/main.js

Lines changed: 36 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/msvc.ts

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,49 @@ export function setUpWindowsEnvironment(
4444
graalVMVersion: string,
4545
isGraalVMforJDK17OrLater: boolean
4646
): void {
47-
if (!needsWindowsEnvironmentSetup(javaVersion, graalVMVersion, isGraalVMforJDK17OrLater)) {
48-
return
49-
}
47+
const isRequired = needsWindowsEnvironmentSetup(javaVersion, graalVMVersion, isGraalVMforJDK17OrLater)
5048

5149
core.startGroup('Updating Windows environment...')
5250

53-
const vcvarsallPath = findVcvarsallPath()
54-
core.debug(`Calling "${vcvarsallPath}"...`)
55-
const [originalEnv, vcvarsallOutput, updatedEnv] = execSync(`set && cls && "${vcvarsallPath}" x64 && cls && set`, {
56-
shell: 'cmd'
57-
})
58-
.toString()
59-
.split('\f') // form feed page break (printed by `cls`)
60-
core.debug(vcvarsallOutput)
51+
try {
52+
const vcvarsallPath = findVcvarsallPath()
53+
core.debug(`Calling "${vcvarsallPath}"...`)
54+
const [originalEnv, vcvarsallOutput, updatedEnv] = execSync(`set && cls && "${vcvarsallPath}" x64 && cls && set`, {
55+
shell: 'cmd'
56+
})
57+
.toString()
58+
.split('\f') // form feed page break (printed by `cls`)
59+
core.debug(vcvarsallOutput)
6160

62-
const originalEnvMap = new Map<string, string>()
63-
for (const line of originalEnv.split('\r\n')) {
64-
if (line.includes('=')) {
65-
const [name, value] = line.split('=')
66-
originalEnvMap.set(name, value)
67-
} else if (line) {
68-
core.debug(`Skipping ${line} (does not include '=')...`)
61+
const originalEnvMap = new Map<string, string>()
62+
for (const line of originalEnv.split('\r\n')) {
63+
if (line.includes('=')) {
64+
const [name, value] = line.split('=')
65+
originalEnvMap.set(name, value)
66+
} else if (line) {
67+
core.debug(`Skipping ${line} (does not include '=')...`)
68+
}
6969
}
70-
}
7170

72-
for (const line of updatedEnv.split('\r\n')) {
73-
if (line.includes('=')) {
74-
const [name, value] = line.split('=')
75-
const originalValue = originalEnvMap.get(name)
76-
if (value !== originalValue) {
77-
core.exportVariable(name, value)
78-
core.debug(`"${name}" set to "${value}"`)
71+
for (const line of updatedEnv.split('\r\n')) {
72+
if (line.includes('=')) {
73+
const [name, value] = line.split('=')
74+
const originalValue = originalEnvMap.get(name)
75+
if (value !== originalValue) {
76+
core.exportVariable(name, value)
77+
core.debug(`"${name}" set to "${value}"`)
78+
}
79+
} else if (line) {
80+
core.debug(`Skipping ${line} (does not include '=')...`)
7981
}
80-
} else if (line) {
81-
core.debug(`Skipping ${line} (does not include '=')...`)
8282
}
83+
} catch (error) {
84+
if (isRequired) {
85+
throw error
86+
}
87+
core.warning(
88+
`${error instanceof Error ? error.message : error}. This is not required for this version of GraalVM but native-image may fail if Visual Studio cannot be detected automatically.`
89+
)
8390
}
8491

8592
core.endGroup()

0 commit comments

Comments
 (0)