Skip to content

Commit 42135e7

Browse files
CopilotRadjammin@gmail.com
authored andcommitted
Fix Windows deployment review findings
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b848851 commit 42135e7

1 file changed

Lines changed: 54 additions & 39 deletions

File tree

‎windows/deploy_windows.ps1‎

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ param (
6161
[string] $NsisUrl = "https://downloads.sourceforge.net/project/nsis/NSIS%203/3.12/nsis-3.12.zip",
6262
[string] $BuildOption = "",
6363
# Toggles for debugging and targeted builds
64-
[switch] $DebugMode
64+
[switch] $DebugMode,
65+
[switch] $Skip64Bit,
66+
[switch] $Skip32Bit
6567
)
6668

6769
# Fail early on all errors
@@ -194,35 +196,6 @@ Function Get-RedirectedUrl {
194196
}
195197
}
196198

197-
function Initialize-Module-Here ($m) { # see https://stackoverflow.com/a/51692402
198-
199-
# If module is imported say that and do nothing
200-
if (Get-Module | Where-Object {$_.Name -eq $m}) {
201-
Write-Log "INFO" "Module $m is already imported."
202-
}
203-
else {
204-
205-
# If module is not imported, but available on disk then import
206-
if (Get-Module -ListAvailable | Where-Object {$_.Name -eq $m}) {
207-
Import-Module $m
208-
}
209-
else {
210-
211-
# If module is not imported, not available on disk, but is in online gallery then install and import
212-
if (Find-Module -Name $m | Where-Object {$_.Name -eq $m}) {
213-
Install-Module -Name $m -Force -Verbose -Scope CurrentUser
214-
Import-Module $m
215-
}
216-
else {
217-
218-
# If module is not imported, not available and not in online gallery then abort
219-
Write-Log "ERROR" "Module $m not imported, not available and not in online gallery, exiting."
220-
EXIT 1
221-
}
222-
}
223-
}
224-
}
225-
226199
# Download and uncompress dependency in ZIP format
227200
Function Install-Dependency
228201
{
@@ -264,14 +237,10 @@ Function Install-Dependency
264237
Remove-Item -Path $TempFileName -Force
265238
}
266239

267-
# Install VSSetup (Visual Studio detection), ASIO SDK and NSIS Installer
240+
# Install ASIO SDK and NSIS Installer
268241
Function Install-Dependencies
269242
{
270243
Write-Log "STEP" "Installing Dependencies..."
271-
if (-not (Get-PackageProvider -Name nuget).Name -eq "nuget") {
272-
Install-PackageProvider -Name "Nuget" -Scope CurrentUser -Force
273-
}
274-
Initialize-Module-Here -m "VSSetup"
275244
Install-Dependency -Uri $NsisUrl -Destination "..\libs\NSIS\NSIS-source"
276245

277246
if ($BuildOption -Notmatch "jack") {
@@ -292,11 +261,41 @@ Function Initialize-Build-Environment
292261
)
293262

294263
# Look for Visual Studio/Build Tools 2017 or later (version 15.0 or above)
295-
$VsInstallPath = Get-VSSetupInstance | `
296-
Select-VSSetupInstance -Product "*" -Version "15.0" -Latest | `
297-
Select-Object -ExpandProperty "InstallationPath"
264+
$VsWhereCandidates = @(
265+
"$env:ProgramFiles(x86)\Microsoft Visual Studio\Installer\vswhere.exe",
266+
"$env:ProgramFiles\Microsoft Visual Studio\Installer\vswhere.exe"
267+
)
268+
$VsWherePath = $VsWhereCandidates | Where-Object { Test-Path -Path $_ } | Select-Object -First 1
298269

299-
if ($VsInstallPath -Eq "") { $VsInstallPath = "<N/A>" }
270+
if (-not $VsWherePath)
271+
{
272+
$VsWhereCommand = Get-Command "vswhere.exe" -ErrorAction SilentlyContinue
273+
if ($VsWhereCommand) { $VsWherePath = $VsWhereCommand.Source }
274+
}
275+
276+
if (-not $VsWherePath)
277+
{
278+
Throw "vswhere.exe could not be located. Please install Visual Studio 2017 or newer."
279+
}
280+
281+
$VsInstallPath = (& "$VsWherePath" -latest -products "*" `
282+
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
283+
-property installationPath 2>$null | Select-Object -First 1)
284+
285+
if ([string]::IsNullOrWhiteSpace($VsInstallPath))
286+
{
287+
$VsInstallPath = (& "$VsWherePath" -latest -products "*" `
288+
-property installationPath 2>$null | Select-Object -First 1)
289+
}
290+
291+
if (-not [string]::IsNullOrWhiteSpace($VsInstallPath))
292+
{
293+
$VsInstallPath = $VsInstallPath.Trim()
294+
}
295+
else
296+
{
297+
$VsInstallPath = "<N/A>"
298+
}
300299

301300
if ($BuildArch -Eq "x86_64")
302301
{
@@ -470,8 +469,24 @@ Function Build-App
470469
# Build and deploy Jamulus 64bit and 32bit variants
471470
function Build-App-Variants
472471
{
472+
if ($Skip64Bit -and $Skip32Bit)
473+
{
474+
Throw "Both 64-bit and 32-bit builds are skipped; no application binaries will be produced."
475+
}
476+
473477
foreach ($_ in ("x86_64", "x86"))
474478
{
479+
if ($_ -eq "x86_64" -and $Skip64Bit)
480+
{
481+
Write-Log "INFO" "Skipping 64-bit build."
482+
continue
483+
}
484+
if ($_ -eq "x86" -and $Skip32Bit)
485+
{
486+
Write-Log "INFO" "Skipping 32-bit build."
487+
continue
488+
}
489+
475490
$OriginalEnv = Get-ChildItem Env:
476491
if ($_ -eq "x86")
477492
{

0 commit comments

Comments
 (0)