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.

Error Codes of App-V 5 Packages

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Guest
Tuesday, August 03 2021

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.