winget-cli
winget-cli copied to clipboard
Install WinGet from terminal / PowerShell
Brief description of your issue
As an windows administrator I want to be able to provision windows machines using WinRM, as a part of provisioning machines I'd like to install WinGet and then use it to install all other programs needed.
There doesn't seem to be any instructions for how to install WinGet with just a remote terminal (using WinRM or alternatively OpenSSH). Nor any instructions for setting up WinGet using PowerShell.
With Chocolatey I just need to run:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
If I can't similarly automate the setup of WinGet and then use it then theres no way to replace Chocolatey with WinGet in my provisioning scripts. Which kind of make WinGet useless for most people? Is this missing functionality or just missing documentation?
The Windows Package Manager is shipped with the "App Installer". If the Windows version already has the "App Installer", automatic updates will pull the latest stable version (containing Windows Package Manager). It may be installed via the Microsoft Store, or the GitHub releases in this repository. I've seen several examples of using PowerShell do install the latter. We will likely include that functionality when we release the stable PowerShell module. The "App Installer" is an MSIX package, so remote execution via system context isn't supported. We are building an in-process COM interface via a NuGet package to enable remote execution via system context.
Related: https://github.com/microsoft/winget-cli/issues/1474 and https://github.com/microsoft/winget-cli/issues/1929
The troubleshooting guide does show a command that should install WinGet from PowerShell locally. Instead it throws a COM Exception.
PS C:\temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe> Add-AppxProvisionedPackage -online -PackagePath '.\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' -LicensePath '.\b0a0692da1034339b76dce1c298a1e42_License1.xml' -DependencyPackagePath '.\Microsoft.VCLibs.x64.14.00.Desktop.appx'
Add-AppxProvisionedPackage : Unspecified error
At line:1 char:1
+ Add-AppxProvisionedPackage -online -PackagePath '.\Microsoft.DesktopA ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AppxProvisionedPackage], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.AddAppxProvisionedPackageCommand
The Repair-WinGetPackageManager cmdlet in the Microsoft.WinGet.Client PowerShell Module does much of the work to handle dependencies, but Microsoft.UI.Xaml is still not handled in the most optimal way. We're looking at some options here to see if we can improve the situation without needing to download and decompress the dependency.
We've also been looking to update the dependency to Microsoft.UI.Xaml 2.8 from 2.7 in WinGet:
- https://github.com/microsoft/winget-cli/issues/3380