Skip to content

Commit 6f0c7d6

Browse files
authored
Pick highest installed MSVC version (#1658)
GitHub keeps changing the builder image out from under us. In this case it looks like they moved it back to the old version we had before. To try and ease the pain simply pick the highest installed MSVC version.
1 parent 075f1d8 commit 6f0c7d6

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

scripts/package.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ main(async () => {
2626
const rootDirectory = getRootDirectory();
2727
const version = await getExtensionVersion();
2828
const versionString = `${version.major}.${version.minor}.${version.patch}`;
29+
30+
if (process.platform === "win32") {
31+
console.log("Packaging the extension is not supported on Windows.");
32+
return process.exit(0);
33+
}
34+
2935
// Update version in CHANGELOG
3036
await updateChangelog(versionString);
3137
// Use VSCE to package the extension

scripts/test_windows.ps1

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ function Update-SwiftBuildAndPackageArguments {
1616
param (
1717
[string]$jsonFilePath = "./assets/test/.vscode/settings.json",
1818
[string]$codeWorkspaceFilePath = "./assets/test.code-workspace",
19-
[string]$windowsSdkVersion = "10.0.22000.0",
20-
[string]$vcToolsVersion = "14.44.35207"
19+
[string]$windowsSdkVersion = "10.0.22000.0"
2120
)
2221

22+
$vcToolsPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC"
23+
$vcToolsVersions = Get-ChildItem -Directory -Path $vcToolsPath | ForEach-Object { $_.Name }
24+
25+
if ($vcToolsVersions.Count -eq 0) {
26+
Write-Host "No versions found in $vcToolsPath"
27+
exit 1
28+
}
29+
30+
$vcToolsVersion = $vcToolsVersions | Sort-Object -Descending | Select-Object -First 1
31+
Write-Host "Highest Visual C++ Tools version: $vcToolsVersion"
32+
2333
$windowsSdkRoot = "C:\Program Files (x86)\Windows Kits\10\"
2434

2535
try {
@@ -39,7 +49,6 @@ function Update-SwiftBuildAndPackageArguments {
3949
if ($jsonContent.PSObject.Properties['swift.buildArguments']) {
4050
$jsonContent.PSObject.Properties.Remove('swift.buildArguments')
4151
}
42-
4352

4453
$jsonContent | Add-Member -MemberType NoteProperty -Name "swift.buildArguments" -Value @(
4554
"-Xbuild-tools-swiftc", "-windows-sdk-root", "-Xbuild-tools-swiftc", $windowsSdkRoot,
@@ -63,7 +72,6 @@ function Update-SwiftBuildAndPackageArguments {
6372
"-Xswiftc", "-visualc-tools-version", "-Xswiftc", $vcToolsVersion
6473
)
6574

66-
6775
$codeWorkspaceContent.PSObject.Properties.Remove('settings')
6876
$codeWorkspaceContent | Add-Member -MemberType NoteProperty -Name "settings" -Value $jsonContent
6977

@@ -88,6 +96,12 @@ if ($LASTEXITCODE -ne 0) {
8896
Write-Host "Swift version:"
8997
Write-Host "$swiftVersionOutput"
9098

99+
Write-Host "Installed MSVC Versions:"
100+
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC"
101+
102+
Write-Host "Installed Windows SDK Versions:"
103+
dir "C:\Program Files (x86)\Windows Kits\10\Include\"
104+
91105
$versionLine = $swiftVersionOutput[0]
92106
if ($versionLine -match "Swift version (\d+)\.(\d+)") {
93107
Write-Host "Matched Swift version: $($matches[0]), $($matches[1]), $($matches[2])"

0 commit comments

Comments
 (0)