|
8 | 8 | # - Install the Windows 10 SDK if it detected a `.windows-10-sdk-version` file(2) |
9 | 9 | # |
10 | 10 | # (1) The certificate it installs is stored in our AWS SecretsManager storage (`windows-code-signing-certificate` secret ID) |
11 | | -# (2) You can skip the Win10 install even if `.windows-10-sdk-version` file is present by using the `SKIP_WINDOWS_10_SDK_INSTALL=1` env var before calling this script |
| 11 | +# (2) You can skip the Windows 10 SDK installation regardless of whether `.windows-10-sdk-version` is present by calling the script with `-SkipWindows10SDKInstallation`. |
12 | 12 | # |
13 | 13 | # Note: In addition to calling this script, and depending on your client app, you might want to also install `npm` and the `Node.js` packages used by your client app on the agent too. For that part, you should use the `automattic/nvm` Buildkite plugin on the pipeline step's `plugins:` attribute. |
14 | 14 | # |
15 | 15 |
|
| 16 | +param ( |
| 17 | + [switch]$SkipWindows10SDKInstallation = $false |
| 18 | +) |
| 19 | + |
16 | 20 | # Stop script execution when a non-terminating error occurs |
17 | 21 | $ErrorActionPreference = "Stop" |
18 | 22 |
|
19 | | -Write-Host "--- :windows: Setting up Windows for app distribution" |
| 23 | +Write-Output "--- :windows: Setting up Windows for app distribution" |
20 | 24 |
|
21 | | -Write-Host "Current working directory: $PWD" |
| 25 | +Write-Output "Current working directory: $PWD" |
22 | 26 |
|
23 | | -Write-Host "Enable long path behavior" |
| 27 | +Write-Output "Enable long path behavior" |
24 | 28 | # See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation |
25 | 29 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 |
26 | 30 |
|
27 | 31 | # Disable Windows Defender before starting – otherwise our performance is terrible |
28 | | -Write-Host "Disable Windows Defender..." |
| 32 | +Write-Output "Disable Windows Defender..." |
29 | 33 | $avPreference = @( |
30 | 34 | @{DisableArchiveScanning = $true} |
31 | 35 | @{DisableAutoExclusions = $true} |
@@ -61,54 +65,59 @@ $avPreference | Foreach-Object { |
61 | 65 | # https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/microsoft-defender-antivirus-compatibility?view=o365-worldwide |
62 | 66 | $atpRegPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection' |
63 | 67 | if (Test-Path $atpRegPath) { |
64 | | - Write-Host "Set Microsoft Defender Antivirus to passive mode" |
| 68 | + Write-Output "Set Microsoft Defender Antivirus to passive mode" |
65 | 69 | Set-ItemProperty -Path $atpRegPath -Name 'ForceDefenderPassiveMode' -Value '1' -Type 'DWORD' |
66 | 70 | } |
67 | 71 |
|
68 | 72 | # From https://stackoverflow.com/a/46760714 |
69 | | -Write-Host "--- :windows: Setting up Package Manager" |
| 73 | +Write-Output "--- :windows: Setting up Package Manager" |
70 | 74 | $env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.." |
71 | 75 | Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" |
72 | 76 |
|
73 | 77 | # This should avoid issues with symlinks not being supported in Windows. |
74 | 78 | # |
75 | 79 | # See how this build failed |
76 | 80 | # https://buildkite.com/automattic/beeper-desktop/builds/2895#01919738-7c6e-4b82-8d1d-1c1800481740 |
77 | | -Write-Host "--- :windows: :linux: Enable developer mode to use symlinks" |
| 81 | +Write-Output "--- :windows: :linux: Enable developer mode to use symlinks" |
78 | 82 |
|
79 | 83 | $developerMode = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux |
80 | 84 |
|
81 | 85 | if ($developerMode.State -eq 'Enabled') { |
82 | | - Write-Host "Developer Mode is already enabled." |
| 86 | + Write-Output "Developer Mode is already enabled." |
83 | 87 | } else { |
84 | | - Write-Host "Enabling Developer Mode..." |
| 88 | + Write-Output "Enabling Developer Mode..." |
85 | 89 | try { |
86 | 90 | Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart |
87 | 91 | } catch { |
88 | | - Write-Host "Failed to enable Developer Mode. Continuing without it..." |
| 92 | + Write-Output "Failed to enable Developer Mode. Continuing without it..." |
89 | 93 | } |
90 | 94 | } |
91 | 95 |
|
92 | | -Write-Host "--- :lock_with_ink_pen: Download Code Signing Certificate" |
| 96 | +Write-Output "--- :lock_with_ink_pen: Download Code Signing Certificate" |
93 | 97 | $certificateBinPath = "certificate.bin" |
94 | 98 | $EncodedText = aws secretsmanager get-secret-value --secret-id windows-code-signing-certificate ` |
95 | 99 | | jq -r '.SecretString' ` |
96 | 100 | | Out-File $certificateBinPath |
97 | 101 | $certificatePfxPath = "certificate.pfx" |
98 | 102 | certutil -decode $certificateBinPath $certificatePfxPath |
99 | | -Write-Host "Code signing certificate downloaded at: $((Get-Item $certificatePfxPath).FullName)" |
| 103 | +Write-Output "Code signing certificate downloaded at: $((Get-Item $certificatePfxPath).FullName)" |
100 | 104 |
|
101 | | -Write-Host "--- :windows: Checking whether to install Windows 10 SDK..." |
| 105 | +Write-Output "--- :windows: Checking whether to install Windows 10 SDK..." |
102 | 106 |
|
103 | 107 | # When using Electron Forge and electron2appx, building Appx requires the Windows 10 SDK |
104 | 108 | # |
105 | 109 | # See https://github.com/hermit99/electron-windows-store/tree/v2.1.2?tab=readme-ov-file#usage |
106 | 110 |
|
| 111 | +if ($SkipWindows10SDKInstallation) { |
| 112 | + Write-Output "Run with SkipWindows10SDKInstallation = true. Skipping Windows 10 SDK installation check." |
| 113 | + exit 0 |
| 114 | +} |
| 115 | + |
107 | 116 | $windowsSDKVersionFile = ".windows-10-sdk-version" |
108 | 117 | if (Test-Path $windowsSDKVersionFile) { |
109 | | - Write-Host "Found $windowsSDKVersionFile file, installing Windows 10 SDK..." |
| 118 | + Write-Output "Found $windowsSDKVersionFile file, installing Windows 10 SDK..." |
110 | 119 | & "$PSScriptRoot\install_windows_10_sdk.ps1" |
111 | 120 | If ($LastExitCode -ne 0) { Exit $LastExitCode } |
112 | 121 | } else { |
113 | | - Write-Host "No $windowsSDKVersionFile file found, skipping Windows 10 SDK installation." |
| 122 | + Write-Output "No $windowsSDKVersionFile file found, skipping Windows 10 SDK installation." |
114 | 123 | } |
0 commit comments