mirror of
https://github.com/microsoft/WSL.git
synced 2026-04-21 03:14:56 -05:00
* tools: update deploy-to-host.ps1 to automatically detect host architecture * pr feedback --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
52 lines
1.3 KiB
PowerShell
52 lines
1.3 KiB
PowerShell
#Requires -RunAsAdministrator
|
|
|
|
[cmdletbinding(PositionalBinding = $false)]
|
|
param (
|
|
[ValidateSet("Debug", "Release")][string]$BuildType = "Debug",
|
|
[string]$BuildOutputPath = [string](Get-Location),
|
|
[string]$PackageCertPath = $null,
|
|
[parameter(ValueFromRemainingArguments = $true)]
|
|
[string[]]$MsiArgs
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$processorArchitecture = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment').PROCESSOR_ARCHITECTURE
|
|
$Platform = switch -Wildcard ($processorArchitecture) {
|
|
'*ARM64*' { 'arm64' }
|
|
'*AMD64*' { 'X64' }
|
|
default { throw "Failed to determine system architecture: $processorArchitecture" }
|
|
}
|
|
|
|
$PackagePath = "$BuildOutputPath\bin\$Platform\$BuildType\wsl.msi"
|
|
|
|
# msiexec.exe doesn't like symlinks, so use the canonical path
|
|
$Target = (Get-ChildItem $PackagePath).Target
|
|
if ($Target)
|
|
{
|
|
$PackagePath = $Target
|
|
}
|
|
|
|
Write-Host -ForegroundColor Green "Installing: $PackagePath "
|
|
|
|
$MSIArguments = @(
|
|
"/i"
|
|
$PackagePath
|
|
"/qn"
|
|
"/norestart"
|
|
)
|
|
|
|
if ($MsiArgs)
|
|
{
|
|
$MSIArguments += $MsiArgs
|
|
}
|
|
|
|
$exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode
|
|
if ($exitCode -Ne 0)
|
|
{
|
|
Write-Host "Failed to install package: $exitCode"
|
|
exit 1
|
|
}
|
|
|
|
Write-Host -ForegroundColor Green "Package $PackagePath installed successfully"
|