9

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?

Leon Bouquiet
  • 4,159
  • 3
  • 25
  • 36
  • For anyone else with the same problem, I just stumbled onto this thread: https://github.com/microsoft/winget-cli/issues/144 – Leon Bouquiet Jun 23 '21 at 18:33

4 Answers4

7

Actually, there is a workaround for installing this. 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.7.3, 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 permit it to download the latest version of winget no matter what.

# Install VCLibs
Add-AppxPackage 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'

# Install Microsoft.UI.Xaml.2.7.3 from NuGet
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3 -OutFile .\microsoft.ui.xaml.2.7.3.zip
Expand-Archive .\microsoft.ui.xaml.2.7.3.zip
Add-AppxPackage .\microsoft.ui.xaml.2.7.3\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.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

If you're looking to use this, just ensure to run it in an empty directory.

Joe
  • 415
  • 1
  • 5
  • 15
3

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

Demitrius Nelon
  • 1,210
  • 1
  • 10
  • 29
3

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"
0

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
}
a0s
  • 479
  • 4
  • 8