Skip to content

Commit

Permalink
fix(WINGET): LTSC & Server support
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Sep 15, 2023
1 parent 956326b commit d74df3a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/playbook/Executables/WINGET.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# Credit: https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget-on-windows-sandbox

$progressPreference = 'silentlyContinue'
$progressPreference = 'SilentlyContinue'

if ($null -eq $(cmd /c where winget)) {$getLatest = $true}
$latestVersion = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/winget-cli/releases/latest" | Select-Object -ExpandProperty tag_name
if ($latestVersion -ne $(winget -v)) {$getLatest = $true}
# Make temporary directory
$tempDir = Join-Path -Path $env:temp -ChildPath $([System.IO.Path]::GetRandomFileName())
New-Item $tempDir -ItemType Directory -Force | Out-Null

if (!(Get-Command winget -ErrorAction SilentlyContinue)) {$getLatest = $true} else {
$latestVersion = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/winget-cli/releases/latest" | Select-Object -ExpandProperty tag_name
if ($latestVersion -ne $(winget -v)) {$getLatest = $true}
}

if ($getLatest) {
Set-Location "C:\Windows\Temp"
Set-Location $tempDir

Write-Information "Downloading WinGet and its dependencies..."
Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -UseBasicParsing
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.7.3/Microsoft.UI.Xaml.2.7.x64.appx -OutFile Microsoft.UI.Xaml.2.7.x64.appx
# Get license for LTSC
$license = (Invoke-RestMethod https://api.github.com/repos/microsoft/winget-cli/releases/latest -UseBasicParsing).Assets | Where-Object { $_.name -like "*License*.xml" }
Invoke-WebRequest -UseBasicParsing -OutFile "license.xml" $license.browser_download_url

Write-Information "Installing WinGet and its dependencies..."
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.UI.Xaml.2.7.x64.appx
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Add-AppxProvisionedPackage -Online -PackagePath .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -LicensePath .\license.xml
}

Write-Information "Configuring WinGet..."
Expand Down

0 comments on commit d74df3a

Please sign in to comment.