winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Install WinGet from terminal / PowerShell

Open TheKnarf opened this issue 3 years ago • 3 comments

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?

TheKnarf avatar Jun 06 '22 19:06 TheKnarf

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.

denelon avatar Jun 06 '22 23:06 denelon

Related: https://github.com/microsoft/winget-cli/issues/1474 and https://github.com/microsoft/winget-cli/issues/1929

jedieaston avatar Jun 07 '22 12:06 jedieaston

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

A9G-Data-Droid avatar Jun 21 '22 16:06 A9G-Data-Droid

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

denelon avatar Jun 28 '23 19:06 denelon