Font size: +
5 minutes reading time (1058 words)

Install WinGet and AppInstaller on Windows Server 2022

MAD_MSIX_1024
The 1.x release for Winget (from Microsoft) has been published. A small command line tool, which can be used to install thousands of applications quickly. can be installed quickly. There are he many blog articles, how to install Winget for Windows 10 (in beta). Unfortunately however, no article on how to make it work on a Windows Server. Basically everything can be installed on Server 2019 after, what is available for Windows 10. We just need to "extract" the Appx and MSIX files for this. Files from the store "extract". With Winget, unfortunately, there was the limitation, that the command line is not yet supported in Server 2019 due to build 1809. is supported. For Server 2022 it's different and when in the last days we installed one of one of the first ISO images of Server 2022 the idea came up right away, Winget there to test and write a short tutorial if it works.
The Winget tool is included in the preview version or insider version of Windows App Installer. We need to install an insider version of App Installer to be able to use be able to use Winget. In this procedure it is mandatory to use Microsoftstore is necessary, which we cannot easily use on Windows Server.

If we can use the Store as we do in Windows 10, one option is to send a request to The insider program for windows package manager. A better way in this case is to download the package directly from Github.


For the "Package Manager" Insider Program we can sign up and here. >>LINK<<
The AppInstaller can be found here in the Microsoft Store >>LINK<<

After installing the app installer from the Insider program, new Commands available in the command line.

  • Install - installs the specified package
  • Show - displays information about a package
  • Source - manages the sources of packages
  • Search - find and display basic information about packages
  • Iist - displays - installed packages
  • Upgrade - performs an upgrade of the specified package
  • Uninstall - uninstalls the specified package
  • Hash - utility for hashing installer files
  • Validate - validates a manifest file
  • Settings - opens settings
  • Features - displays the status of experimental features
  • Export - exports a list of installed packages
  • Import - installs all packages in one file

A search operation is performed with "Search":

A Winget installation with "Install":

A version with the Winget tool winds up as a release and MSIX package in Github. (since recently as version 1.x). There exists the download :
Windows Package Manager v1.0.11692

With which under Windows 10 easily a version with Winget can be post-installed without having to use the store (a double click is enough).
Now. we want to install the whole thing as automated as possible and with all dependencies. this time on server 2022.

After downloading the "msixbuldle" from the release page, we see in the package. AppInstaller_X64.msix a dependency on a VCLib. These are more or less the MSIX equivalent to the Visual C++ runtime environments. In this case this is a prerequisite that must be installed on a 2022 server for the app installer to work works with Winget.

Extract from the AppxManifest:

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.18362.0"/>
<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.29231.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>
</Dependencies> 

We first need to get this package from the store in the appropriate architecture extract. Using the URL https://store.rg-adguard.net/, we can get the download URL for our component pretty easily to the download URL for our component. By the way, you can also find always a version in the current Windows Kit. First we download VC140.00 as Appx package with the following script and install the package with Add-AppPackage. User rights are enough.

# Install-VCLibs.140.00 Version 14.0.30035
# Andreas Nick 2021

$StoreLink = 'https://www.microsoft.com/de-de/p/app-installer/9nblggh4nns1'
$StorePackageName = 'Microsoft.VCLibs.140.00.UWPDesktop_14.0.30035.0_x64__8wekyb3d8bbwe.appx'

$RepoName = 'AppPAckages'
$RepoLokation = $env:Temp
$Packagename = 'Microsoft.VCLibs.140.00'
$RepoPath = Join-Path $RepoLokation -ChildPath $RepoName 
$RepoPath = Join-Path $RepoPath -ChildPath $Packagename


#
# Function Source
# Idea from: https://serverfault.com/questions/1018220/how-do-i-install-an-app-from-windows-store-using-powershell
# modificated version. Now able to filte and return msix url's
#

function Download-AppPackage {
[CmdletBinding()]
param (
  [string]$Uri,
  [string]$Filter = '.*' #Regex
)
   
  process {

    #$Uri=$StoreLink

    $WebResponse = Invoke-WebRequest -UseBasicParsing -Method 'POST' -Uri 'https://store.rg-adguard.net/api/GetFiles' -Body "type=url&url=$Uri&ring=Retail" -ContentType 'application/x-www-form-urlencoded'
    
    $result =$WebResponse.Links.outerHtml | Where-Object {($_ -like '*.appx*') -or ($_ -like '*.msix*')} | Where-Object {$_ -like '*_neutral_*' -or $_ -like "*_"+$env:PROCESSOR_ARCHITECTURE.Replace("AMD","X").Replace("IA","X")+"_*"} | ForEach-Object {
       $result = "" | Select-Object -Property filename, downloadurl
       
       if( $_ -match '(?<=rel="noreferrer">).+(?=</a>)' )
       {
         $result.filename = $matches.Values[0]
       }

       if( $_ -match '(?<=a href=").+(?=" r)' )
       {
         $result.downloadurl = $matches.Values[0]
       }
       $result
    } 
    
    
    $result | Where-Object -Property filename -Match $filter 
  }
}



$package = Download-AppPackage -Uri $StoreLink  -Filter $StorePackageName

if(-not (Test-Path $RepoPath ))
{
    New-Item $RepoPath -ItemType Directory -Force
}


if(-not (Test-Path (Join-Path $RepoPath -ChildPath $package.filename )))
{
    Invoke-WebRequest -Uri $($package.downloadurl) -OutFile (Join-Path $RepoPath -ChildPath $package.filename )
} else 
{
    Write-Information "The file $($package.filename) already exist in the repo. Skip download"
}

#Install the Runtime
add-AppPackage (Join-Path $RepoPath -ChildPath $package.filename )
 

Then we download the Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle package from the GitHub repository and install the package using AppAppPackage.

# Install-Winget Version v1.0.11692
# Andreas Nick 2021

# From github
$WinGet_Link = 'https://github.com/microsoft/winget-cli/releases/download/v1.0.11692/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
$WinGet_Name = 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'

$RepoName = 'AppPAckages'
$RepoLokation = $env:Temp
$Packagename = 'Winget'

$RepoPath = Join-Path $RepoLokation -ChildPath $RepoName 
$RepoPath = Join-Path $RepoPath -ChildPath $Packagename

if(-not (Test-Path $RepoPath ))
{
    New-Item $RepoPath -ItemType Directory -Force
}


if(-not (Test-Path (Join-Path $RepoPath -ChildPath  $WinGet_Name )))
{
    Invoke-WebRequest -Uri $WinGet_Link -OutFile (Join-Path $RepoPath -ChildPath $WinGet_Name )
} else 
{
    Write-Information "The file $WinGet_Name already exist in the repo. Skip download"
}

#Install the Package
Add-AppPackage (Join-Path $RepoPath -ChildPath $WinGet_Name)
 

Once that happens, Winget on Server 2022 can be used from the command line. Of course, this is how it will work on Windows 10.
On top of that, AppInstaller is now available. With an AppInstaller configuration file you can automatically update applications like Winget. You can find more information about this in the Microsoft documentation or from me in our MSIX course:

https://docs.microsoft.com/en-us/windows/msix/app-installer/app-installer-file-overview

With the AppInstaller a double click on a MSIX, AppX or a msixbundle is integrated in the system. A dialog for installation appears when the double click is done.

Finally, a picture of a new Server 2022 showing Winget integration.

×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Winget on Server 2019
Error Codes of App-V 5 Packages

Related Posts

 

Comments 9

Guest - bentman (website) on Friday, October 20, 2023 09:59

Thanks! helped with this script to install Dev Tools on Windows Server 2022 -
Add-DevToMyWinServer.ps1

Thanks! helped with this script to install Dev Tools on Windows Server 2022 - [url=https://gist.github.com/bentman/638c478ae791598780c70749139e382f]Add-DevToMyWinServer.ps1[/url]
Guest - Milan on Tuesday, May 30, 2023 16:03

https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3
Download, rename too .zip, unzip to folder

Add-AppxPackage -Path "C:\INSTALL\WINGET\microsoft.ui.xaml.2.7.3\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx"

Add-AppxPackage ".\Microsoft.VCLibs.x64.14.00.Desktop.appx"

Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3 Download, rename too .zip, unzip to folder Add-AppxPackage -Path "C:\INSTALL\WINGET\microsoft.ui.xaml.2.7.3\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx" Add-AppxPackage ".\Microsoft.VCLibs.x64.14.00.Desktop.appx" Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Guest - DC on Wednesday, January 18, 2023 12:49

VCLIB installer script is not working on Datacenter 2022. Pops open the PS shell then closes quickly. Second script seems to work but winget is still an unrecognized command. Thoughts?

VCLIB installer script is not working on Datacenter 2022. Pops open the PS shell then closes quickly. Second script seems to work but winget is still an unrecognized command. Thoughts?
Andreas Nick on Thursday, March 30, 2023 13:27

Sorry for the late reply but notifications have stopped working! Maybe the execution policy for the PowerShell is missing? I would run this in the ISE.

Sorry for the late reply but notifications have stopped working! Maybe the execution policy for the PowerShell is missing? I would run this in the ISE.
Guest - Sassan on Wednesday, August 31, 2022 00:00

fresh install of server 2022

fails with

add-AppPackage : Deployment failed with HRESULT: 0x80073CF0, Package could not be opened.
error 0x80070003: Opening the package from location failed.
NOTE: For additional information, look for [ActivityId] e85da987-bcb8-0000-f6c3-5de8b8bcd801 in the Event Log or use the command line Get-AppPackageLog -ActivityID
e85da987-bcb8-0000-f6c3-5de8b8bcd801
At line:72 char:1
+ add-AppPackage (Join-Path $RepoPath -ChildPath $package.filename )
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (C:\Users\ADMINI....VCLibs.140.00\:String) [Add-AppxPackage], FileNotFoundException
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

fresh install of server 2022 fails with add-AppPackage : Deployment failed with HRESULT: 0x80073CF0, Package could not be opened. error 0x80070003: Opening the package from location failed. NOTE: For additional information, look for [ActivityId] e85da987-bcb8-0000-f6c3-5de8b8bcd801 in the Event Log or use the command line Get-AppPackageLog -ActivityID e85da987-bcb8-0000-f6c3-5de8b8bcd801 At line:72 char:1 + add-AppPackage (Join-Path $RepoPath -ChildPath $package.filename ) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (C:\Users\ADMINI....VCLibs.140.00\:String) [Add-AppxPackage], FileNotFoundException + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand
Guest - YenLegion on Thursday, August 04, 2022 05:19

I am getting

Import-Module: Operation is not supported on this platform. (0x80131539)

I am getting [quote]Import-Module: Operation is not supported on this platform. (0x80131539)[/quote]
Andreas Nick on Thursday, March 30, 2023 13:30

Sorry for the late reply but notifications have stopped working! No module is imported. The error must have another cause. Which PowerShell version are you using?

Sorry for the late reply but notifications have stopped working! No module is imported. The error must have another cause. Which PowerShell version are you using?
Guest - setee on Sunday, September 05, 2021 07:02

This is just want I need

This is just want I need
Guest - Nissan on Tuesday, August 31, 2021 11:57

Thank you , I just get the server 2022 on ... , and want to install the WinGet and AppInstaller, and per your instruction , everything is running now

Thank you , I just get the server 2022 on ... , and want to install the WinGet and AppInstaller, and per your instruction , everything is running now
Already Registered? Login Here
Friday, March 29, 2024

Captcha Image

@nickinformation Tweets

My german Blog: 

http://www.software-virtualisierung.de

in 

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.