-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Greetings,
As a brand new winget user, it was painful to get up and running with this software.
This is an issue to request that:
- Better documentation should exist; please integrate my work below.
- The installer should automatically install the require VCLibs dependency, if necessary. If that is not possible for some technical reason, then a missing VSLibs should be detected and the user should be shown a clear and actionable error message. The existing state of affairs is bad UX; no software should be silently failing.
- The installer should detect if a license is specified and if it isn't, prevent the software from being installed while simultaneously showing the user the correct command for specifying a license. It doesn't make sense to allow an unlicensed version to be successfully installed when it results in bricked software.
- The installer should not return until
wingetis actually in the path. This leads to broken scripts and hard-to-troubleshoot behavior.
I'll do my part to help document what I know in this issue, and I leave it to others to do a pull request and/or integrate this information. In the meantime, this may be useful to other users searching through the GitHub issues.
How to Install winget on Windows 10 LTSC / Windows 10 IoT / Windows Server
Summary
- The official README.md file suggests that you should use the Microsoft Store to get
winget. - However, this is not possible on Windows 10 LTSC, Windows 10 IoT, or Windows Server, because those operating systems do not have the Microsoft Store installed. Furthermore, it is not possible to manually install the Microsoft Store on those operating systems. (Nor would you want to. π)
- In short, the solution is to manually install the
msixbundlefile from the GitHub releases page. - I can verify that the following steps work properly for Windows 10 LTSC 2021, but not other operating systems. With that said, I imagine that the same steps would work.
Compatibility
winget will work on:
- LTSC 2019 (build 1809)
- LTSC 2021 (build 21H2)
It isn't compatible with earlier versions of LTSC.
I don't know the specific versions of Windows Server or Windows IoT that it will work on, if any.
Step 1
- Download Microsoft.VCLibs.x64.14.00.Desktop.appx. (Assuming that you are running on a x64 OS.)
- For reference, the above direct download link is from Microsoft's C++ Runtime framework packages for Desktop Bridge documentation.
- Install it with the following PowerShell command in an elevated/administrator shell:
Add-AppxProvisionedPackage -Online -PackagePath "C:\Microsoft.VCLibs.x64.14.00.Desktop.appx" -SkipLicense- Note that instead of using
AppxProvisionedPackagehere, you could also useAppxPackage. The difference is that:AppxProvisionedPackagewill install in a system context (e.g. each new user on a Windows image will get this installed)AppxPackageinstalls only for a specific user.
- Also note that without this dependency installed, the
wingetinstaller will silently fail (without any error/warning messages). Specifically, the "winget.exe" file will not be added to "C:\Users[Username]\AppData\Local\Microsoft\WindowsApps".
Step 2
- On the GitHub releases page, find the latest version that does not have a "Pre-release" tag. For reference, at the time of this writing, the latest non-pre-release version is v1.1.12653.
- Download both the "msixbundle" file and the "License1.xml" file. For reference, at the time of this writing, this is "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" and "9c0fe2ce7f8e410eb4a8f417de74517e_License1.xml", respectively.
- Install it with the following Powershell command in an elevated/administrator shell:
Add-AppxProvisionedPackage -Online -PackagePath "C:\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -LicensePath "C:\9c0fe2ce7f8e410eb4a8f417de74517e_License1.xml"Now, you should see the "winget.exe" file appear at "C:\Users[Username]\AppData\Local\Microsoft\WindowsApps". Furthermore, it should also be automatically added to your path.
Gotchas
The point at which winget is added to the path seems random. Sometimes, a sleep of 5 seconds works. Other times, I have to restart my whole computer to get it to show up. So your mileage may vary.
Using winget on First Boot
- Obviously, if you plan to use
wingetas your primary package manager, you will want to either:- integrate it into the Windows source with DISM, or
- install it automatically on the first boot with a PowerShell script
- (2) is the simpler option, but I would not recommend it, as the
wingetinstaller seems to be unreliable. I was not able to getwingetto appear in the PATH in post-installation scripts in a consistent way; your mileage may vary.
1) Integrating with DISM (recommended)
If you've used DISM before to e.g. integrate drivers into a Windows installation source, this process is almost exactly the same.
The following is a reference batch script to accomplish this:
rem Mount the Windows installation source
dism /Mount-Wim /WimFile:"C:\MyWindowsSource\sources\install.wim" /Index:1 /MountDir:"C:\mount"
rem Integrate winget
dism /Image:"C:\mount" /Add-ProvisionedAppxPackage /PackagePath:"C:\winget\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" /DependencyPackagePath:"C:\winget\Microsoft.VCLibs.x64.14.00.Desktop.appx" /LicensePath:"C:\winget\9c0fe2ce7f8e410eb4a8f417de74517e_License1.xml" /region=all
rem Save the changes
dism /unmount-wim /mountdir:"C:\mount" /commit2) Using autounattend.xml + PowerShell (not recommended)
- The "autounattend.xml" file is the file that you stick inside of a Windows source to automate the install, perform additional registry tweaks, and so on.
- The "autounattend.xml" file can run arbitrary commands, so if you want it to install
winget, you have two main options:- You can integrate a PowerShell script into the Windows source itself using DISM, and then execute it directly from "autounattend.xml".
- Or, you can download a script from the Internet (using e.g.
curl) and then execute that. (This is the simplest way, but you may not want your script to be public, or you may not have internet access on first boot, etc.)
- For reference, here is an "autounattend.xml" file that launches a PowerShell script on first boot. (In real life, you would want to integrate the "SynchronousCommand" section into your existing "autounattend.xml" file that automates all of the rest of the Windows setup and so on, which is outside the scope of this tutorial.)
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FirstLogonCommands>
<!--
The PowerShell script will take a long time to execute,
but for some reason, Windows will not wait for it to complete,
and will instead boot as normal. The PowerShell window will be
visible and will continue to run.
-->
<SynchronousCommand wcm:action="add">
<Order>100</Order>
<Description></Description>
<CommandLine>powershell -ExecutionPolicy Unrestricted "C:\Windows\Setup\Scripts\install-winget.ps1"</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>
</component>
</settings>
</unattend>install-winget.ps1:
# Install winget
Add-AppxPackage "C:\Windows\Setup\Scripts\winget\Microsoft.VCLibs.x64.14.00.Desktop.appx"
Add-AppxProvisionedPackage -Online -PackagePath "C:\Windows\Setup\Scripts\winget\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -LicensePath "C:\Windows\Setup\Scripts\winget\9c0fe2ce7f8e410eb4a8f417de74517e_License1.xml"
# Sleep for 5 seconds to let winget get into the path because the installer is a buggy mess
# If this does not work, try restarting the entire computer and installing the subsequent software on the next boot
Start-Sleep -s 5
# Install software
winget install --accept-source-agreements --silent --exact --id "Microsoft.VisualStudioCode"
winget install --accept-source-agreements --silent --exact --id "Notepad++.Notepad++"
winget install --accept-source-agreements --silent --exact --id "Git.Git"