Reputation: 4382
I'm trying to install WinGet on a Windows Server 2019 (Standard Edition, Version 1809, Build 17763), but I can't get it to work...
When trying the "install directly" link from this blog post I get the following link ms-appinstaller:?source=https://aka.ms/getwinget
which my browser doesn't understand because I don't have the App Installer.
So I downloaded the Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle
from the GitHub releases page mentioned in the same blog post (which should contain both the App Installer and WinGet). Because my system doesn't get .appxbundle files I tried installing it using Powershell:
Add-AppxPackage ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle"
But it complains that it misses Microsoft.VCLibs.140.00.UWPDesktop
:
Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF3, Package failed updates,
dependency or conflict validation.
Windows cannot install package Microsoft.DesktopAppInstaller_1.11.11451.0_x64__8wekyb3d8bbwe
because this package depends on a framework that could not be found. Provide the framework
"Microsoft.VCLibs.140.00.UWPDesktop" published by "CN=Microsoft Corporation, O=Microsoft
Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor architecture and
minimum version 14.0.29231.0, along with this package to install. The frameworks with name
"Microsoft.VCLibs.140.00.UWPDesktop" currently installed
Apparently, this is a "C++ Runtime framework packages for Desktop Bridge" that can also be downloaded as an appx; installing it first and then installing the DesktopAppInstaller/WinGet bundle goes without errors:
Add-AppxPackage ".\Microsoft.VCLibs.x64.14.00.Desktop.appx"
Add-AppxPackage ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle"
However, at this point I seem to have the App Installer (as it now recognises the .appx/.appxbundle files), but not the WinGet client, because when I run it from a command prompt it tells me:
'winget' is not recognized as an internal or external command, operable program or batch file.
How can I get WinGet to work on a Windows Server 2019 machine?
Upvotes: 21
Views: 69489
Reputation: 559
VCLibs.140.00.UWPDesktop
You can download the Microsoft Visual C++ UWP Desktop Runtime Package from the official Microsoft Download Center. This package includes a README file which links to the version 14.0.33519.0 of Microsoft.VCLibs.140.00.UWPDesktop
https://www.microsoft.com/en-us/download/details.aspx?id=102159
Or additionally, you can just make use of the updated script below which downloads all this for you.
Referencing one of the comments for winget issue #1861 we can see that all we have to do is download VCLibs, Microsoft.UI.XAML.2.8.6, install it using Add-AppxPackage
, download Microsoft.DesktopInstaller and install that as well in order to run winget on a server.
Below is a slightly (not much) modified version of the comment referenced in #1861. It's modified to download the latest version of winget each time it's run alongside its matching dependencies it's published alongside with.
# Disable web request progressbar (Feel free to omit this line)
$ProgressPreference = 'SilentlyContinue'
# Install VCLibs
Add-AppxPackage 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
# Download VCLibs (UWP) and Microsoft.UI.Xaml
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.9.25180/DesktopAppInstaller_Dependencies.zip -OutFile .\DesktopAppInstaller_Dependencies.zip
# Install VCLibs (UWP)
# Attrib: https://github.com/microsoft/winget-pkgs/blob/master/manifests/m/Microsoft/VCLibs/Desktop/14/14.0.33728.0/Microsoft.VCLibs.Desktop.14.installer.yaml#L15
Expand-Archive .\DesktopAppInstaller_Dependencies.zip
Add-AppxPackage .\DesktopAppInstaller_Dependencies\x64\Microsoft.VCLibs.140.00.UWPDesktop_14.0.33728.0_x64.appx
# Install Microsoft.UI.Xaml
Add-AppxPackage .\DesktopAppInstaller_Dependencies\x64\Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64.appx
# Install the latest release of Microsoft.DesktopAppInstaller from GitHub
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Add-AppxPackage .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
If you're looking to use this, just ensure to run it in an empty directory.
Upvotes: 16
Reputation: 4382
There's a script on github which I've successfully used to install WinGet with, see here:
As copied from there:
# inspired by https://gist.github.com/likamrat/cae833a6e5b3461709f14c093c21c293?permalink_comment_id=5065503#gistcomment-5065503
# Create download directory
if (-not $(Test-Path -Path "C:\WinGet")) {
New-Item -Path "C:" -Name "WinGet" -ItemType Directory -Force
}
# Dependencies
Remove-Item "C:\WinGet\" -Recurse -Force
New-Item -Path "C:\WinGet" -ItemType Directory -Force
## Microsoft.UI.Xaml
$UIXamlPath = "C:\WinGet\Microsoft.UI.Xaml.zip"
$downloadUIXamlUri = "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.6"
Invoke-WebRequest $downloadUIXamlUri -outfile $UIXamlPath # (New-Object System.Net.WebClient).DownloadFile($downloadUIXamlUri, $UIXamlPath)
Unblock-File -Path $UIXamlPath
Expand-Archive -Path $UIXamlPath -DestinationPath "C:\WinGet\Microsoft.UI.Xaml.2.8.6"
$UIXamlAppxPath = "C:\WinGet\Microsoft.UI.Xaml.2.8.6\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.8.appx"
Add-AppxPackage -Path $UIXamlAppxPath
## Microsoft.VCLibs.x64.14.00.Desktop
$VCLibsPath = "C:\WinGet\Microsoft.VCLibs.x64.14.00.Desktop.appx"
$downloadVClibsUri = "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx"
Invoke-WebRequest $downloadVClibsUri -outfile $VCLibsPath # (New-Object System.Net.WebClient).DownloadFile($downloadVClibsUri, $VCLibsPath)
Unblock-File -Path $VCLibsPath
Add-AppxPackage -Path $VCLibsPath
# Main Package
# Get the newest WinGet's version the download URL
$assetPattern = "*Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
$releasesUri = "https://api.github.com/repos/microsoft/winget-cli/releases/latest"
$asset = (Invoke-RestMethod -Uri $releasesUri -Method Get -ErrorAction stop).assets | Where-Object name -like $assetPattern
$downloadAssetUri = $asset.browser_download_url
# Download newest version of WinGet
$installerPath = "C:\WinGet\$($asset.name)"
Invoke-WebRequest $downloadAssetUri -outfile $installerPath # (New-Object System.Net.WebClient).DownloadFile($downloadAssetUri, $installerPath)
Unblock-File -Path $installerPath
# Get the newest WinGet's license file download URL
$licensePattern = "*_License1.xml"
$license = (Invoke-RestMethod -Uri $releasesUri -Method Get -ErrorAction stop).assets | Where-Object name -like $licensePattern
$downloadLicenseUri = $license.browser_download_url
# Download license file
$licensePath = "C:\WinGet\$($license.name)"
Invoke-WebRequest $downloadLicenseUri -outfile $licensePath # (New-Object System.Net.WebClient).DownloadFile($downloadLicenseUri, $licensePath)
Unblock-File -Path $licensePath
# Install Package
Add-AppxPackage $installerPath
# Register Package with License
Try {
Add-AppxProvisionedPackage -Online -PackagePath $installerPath -LicensePath $licensePath -Verbose -LogPath "C:\WinGet\DesktopAppInstaller_Install.log" #-DependencyPackagePath "$UIXamlAppxPath", "$VCLibsPath"
}
Catch {
try {
Add-AppxPackage -Path $installerPath -DependencyPath "$UIXamlAppxPath", "$VCLibsPath" -InstallAllResources
}
catch {
Write-Output $_.Exception.Message
Write-Output $Error[0]
}
}
# Fix Permissions (S-1-5-32-544) Local Administrators Group (Language independent)
TAKEOWN /F "C:\Program Files\WindowsApps" /R /A /D Y
ICACLS "C:\Program Files\WindowsApps" /grant "*S-1-5-32-544:(F)" /T
# Add Environment Path
$ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
if ($ResolveWingetPath) {
$WingetPath = $ResolveWingetPath[-1].Path
}
$ENV:PATH += ";$WingetPath"
$SystemEnvPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine)
$SystemEnvPath += ";$WingetPath;"
Upvotes: -1
Reputation: 724
This worked flawless for me with Windows Server 2022:
https://www.powershellgallery.com/packages/winget-install
PS> Install-Script -Name winget-install
PS> winget-install
Upvotes: 13
Reputation: 1
Above steps were very helpful but for me it worked as below. I had to update the versions for Microsoft.UI.Xaml and for my WIndows Server 2019 VM in Azure I had to also install VC++ x64 executable.
if (-not (Get-PackageProvider -Name NuGet) -or (Get-PackageProvider -Name NuGet).version -lt 2.8.5.201 ) {
try {
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Confirm:$False -Force
}
catch {
Write-Error -Message $_.Exception
}
}
try {
winget --version
}
catch
{
# Install VC++ x64 executable
Invoke-WebRequest -Uri https://aka.ms/vs/16/release/vc_redist.x64.exe -OutFile .\vc_redist.x64.exe
Start-Process .\vc_redist.x64.exe /S -NoNewWindow -Wait -PassThru
# Install Microsoft.UI.Xaml.2.8.6 from NuGet
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.6 -OutFile .\microsoft.ui.xaml.2.8.6.zip
Expand-Archive .\microsoft.ui.xaml.2.8.6.zip -Force
Add-AppxPackage .\microsoft.ui.xaml.2.8.6\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.8.appx
# Install the latest release of Microsoft.DesktopInstaller from GitHub
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Add-AppxPackage .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
$ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
if ($ResolveWingetPath){
$WingetPath = $ResolveWingetPath[-1].Path
$ENV:PATH += ";$WingetPath"
}
}
Upvotes: 0
Reputation: 1248
Windows Server 2019, and Windows Server 2022 aren't supported. It may be possible to install the Windows Package Manager, but the dependencies aren't included in those SKUs.
https://github.com/microsoft/winget-cli/issues/754#issuecomment-902798802
edited:2024/03/26
The Microsoft.WinGet.Client PowerShell module has a Repair-WinGetPackageManager cmdlet which should bootstrap WinGet and its dependencies. The CLI App Execution Alias isn't supported on Windows Server 2019 though. With PowerShell 7 the majority of the other cmdlets will work even without WinGet installed, but a couple still call the CLI under the hood.
Upvotes: 3
Reputation: 506
The better variant of @Jonathan's script - in case we don't know exactly version of DesktopAppInstaller:
$folderMask = "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*"
$folders = Get-ChildItem -Path $folderMask -Directory | Where-Object { $_.Name -like "*_x64_*" }
foreach ($folder in $folders) {
$folderPath = $folder.FullName
TAKEOWN /F $folderPath /R /A /D Y
ICACLS $folderPath /grant Administrators:F /T
}
Upvotes: 2
Reputation: 81
The above workaround almost did it. I had to fix permissions:
TAKEOWN /F "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.19.10173.0_x64__8wekyb3d8bbwe" /R /A /D Y
ICACLS "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.19.10173.0_x64__8wekyb3d8bbwe" /grant Administrators:F /T
and also add to shell path. Within an existing Powershell instance:
$ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
if ($ResolveWingetPath){
$WingetPath = $ResolveWingetPath[-1].Path
}
$ENV:PATH += ";$WingetPath"
Upvotes: 7