aboutsummaryrefslogtreecommitdiffstats
path: root/packaging
diff options
context:
space:
mode:
Diffstat (limited to 'packaging')
-rw-r--r--packaging/win/electron-builder.msix.yml9
-rw-r--r--packaging/win/ensure-node-path.ps160
2 files changed, 69 insertions, 0 deletions
diff --git a/packaging/win/electron-builder.msix.yml b/packaging/win/electron-builder.msix.yml
index 4026d46..5e45598 100644
--- a/packaging/win/electron-builder.msix.yml
+++ b/packaging/win/electron-builder.msix.yml
@@ -61,6 +61,15 @@ win:
to: service.ps1
- from: ../../packaging/win/service-mode.ps1
to: service-mode.ps1
+ # Full's own installer adds node-runtime\ to the per-user PATH at install
+ # time (build/installer.nsh's customInstall) -- an unelevated HKCU write,
+ # never blocked by the no-elevation rule this target is built around, but
+ # MSIX has no install-time hook at all to run it from. main.js's
+ # winEnsureNodeOnPath() calls this itself on first launch instead
+ # (found missing by actually sideloading a build and checking, not
+ # anticipated in the original plan).
+ - from: ../../packaging/win/ensure-node-path.ps1
+ to: ensure-node-path.ps1
appx:
# --- Real values, from Partner Center's "App identity" page (App
diff --git a/packaging/win/ensure-node-path.ps1 b/packaging/win/ensure-node-path.ps1
new file mode 100644
index 0000000..f9b6f68
--- /dev/null
+++ b/packaging/win/ensure-node-path.ps1
@@ -0,0 +1,60 @@
+<#
+.SYNOPSIS
+ Add the bundled node-runtime directory to the per-user PATH, if it is not
+ there already.
+
+.DESCRIPTION
+ build/installer.nsh's customInstall does this at install time for the NSIS
+ Full target (HKCU\Environment, no elevation -- a per-user registry write
+ needs none). An AppX/MSIX install has no install-time hook at all, elevated
+ or not -- not a signing/elevation gap like the firewall rule or
+ service-mode, but the more basic fact that MSIX runs no custom code
+ whatsoever during setup. So the MSIX target calls this itself, once, on
+ first launch (main.js's winEnsureNodeOnPath()) instead.
+
+ Idempotent and safe to run on every launch of any packaged Windows build,
+ NSIS Full included: if the installer already added the entry, this is a
+ fast no-op query. Never touches PATH for a Light install (no bundled
+ node-runtime to add) -- the caller only invokes this when
+ hasBundledNode() is true.
+
+ Broadcasts WM_SETTINGCHANGE afterward so already-open shells notice --
+ same as the installer's own SendMessage call. New shells pick it up
+ either way.
+
+.PARAMETER NodeDir
+ Full path to the node-runtime directory to add.
+#>
+[CmdletBinding()]
+param(
+ [Parameter(Mandatory = $true)][string]$NodeDir
+)
+
+$ErrorActionPreference = "Stop"
+
+$key = "Registry::HKEY_CURRENT_USER\Environment"
+$current = (Get-ItemProperty -Path $key -Name "Path" -ErrorAction SilentlyContinue).Path
+if ($null -eq $current) { $current = "" }
+
+$parts = $current -split ";" | Where-Object { $_ -ne "" }
+$already = $parts | Where-Object { $_.TrimEnd('\') -ieq $NodeDir.TrimEnd('\') }
+if ($already) {
+ Write-Output "already present"
+ exit 0
+}
+
+$next = if ($parts.Count -gt 0) { ($parts + $NodeDir) -join ";" } else { $NodeDir }
+# ExpandString, not String -- matches installer.nsh's WriteRegExpandStr, so any
+# %VAR% another entry already carries on this machine keeps expanding.
+New-ItemProperty -Path $key -Name "Path" -Value $next -PropertyType ExpandString -Force | Out-Null
+
+Add-Type -Namespace MeshBay -Name NativeMethods -MemberDefinition @"
+ [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ public static extern System.IntPtr SendMessageTimeout(System.IntPtr hWnd, uint Msg, System.UIntPtr wParam, string lParam, uint fuFlags, uint uTimeout, out System.UIntPtr lpdwResult);
+"@
+$HWND_BROADCAST = [IntPtr]0xffff
+$WM_SETTINGCHANGE = 0x1a
+$result = [UIntPtr]::Zero
+[MeshBay.NativeMethods]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [UIntPtr]::Zero, "Environment", 2, 5000, [ref]$result) | Out-Null
+
+Write-Output "added"