Skip to content

Instantly share code, notes, and snippets.

@cdhunt
Created August 5, 2022 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdhunt/4425d986d4011b8fe6b749abdb5754af to your computer and use it in GitHub Desktop.
Save cdhunt/4425d986d4011b8fe6b749abdb5754af to your computer and use it in GitHub Desktop.
This will grab the WinGet appx file and two dependencies and install without user interaction.
function Install-WinGet() {
Write-Information "[winget] Downloading Appx packages"
Push-Location $env:TEMP
# https://github.com/microsoft/winget-cli/issues/2230
if (-not (Test-Path 'Microsoft.DesktopAppInstaller.msixbundle')) {
Write-Information "`tMicrosoft.DesktopAppInstaller"
Invoke-WebRequest 'https://aka.ms/getwinget' -OutFile 'Microsoft.DesktopAppInstaller.msixbundle' -UseBasicParsing
}
if (-not (Test-Path 'Microsoft.UI.Xaml.zip')) {
Write-Information "`tMicrosoft.UI.Xaml"
Invoke-WebRequest 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.1' -OutFile 'Microsoft.UI.Xaml.zip' -UseBasicParsing
}
if (-not (Test-Path 'Microsoft.VCLibs.x64.14.Desktop.appx')) {
Write-Information "`tMicrosoft.VCLibs.x64.14"
Invoke-WebRequest 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx' -OutFile 'Microsoft.VCLibs.x64.14.Desktop.appx' -UseBasicParsing
}
if (-not (Test-Path '.\Microsoft.UI.Xaml\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx')) { Expand-Archive 'Microsoft.UI.Xaml.zip' }
Write-Information "[winget] Installing"
Add-AppxPackage 'Microsoft.DesktopAppInstaller.msixbundle' -DependencyPath '.\Microsoft.UI.Xaml\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx', '.\Microsoft.VCLibs.x64.14.Desktop.appx'
Pop-Location
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment