In many ways the installation of Winget can be transparent to the user if they use the Windows store but for newly provisioned or older Windows 10 devices the installation for Winget via a script isn’t quite as simple as it should be. In this blog post I’ll go over some of the challenges and how they can be overcome. You can reference the script on Github over here: kkaminsk/Install-Winget (github.com)
Winget Installation Requirements
Winget, the Microsoft Windows Package Manager, has come to be recognized as a quintessential tool for many Windows users. The ability to quickly and easily install applications from the command line can significantly streamline workflows and reduce the time it takes to set up new machines. However, like any other software, Winget does come with its own set of requirements for installation. Understanding these requirements will not only ensure a smooth installation but will also provide insights into the intricacies of software dependency chains.
The Winget Package Breakdown
For a successful Winget installation, the following packages must be installed:
- Winget (MSIX Bundle): This is the main package, and it forms the core of the Winget system.
- VC++ Libraries V14: Vital for many Windows applications, these libraries are a set of runtime components that allow C++ apps to run on a computer even if Visual Studio is not installed.
- NuGet: A surprise to some, NuGet, which is primarily known as the .NET package manager, is critical in this installation process. While it might seem out of place in the context of a Windows package manager, its presence is instrumental.
- Microsoft UI XAML 2.7: A framework for creating desktop applications on Windows, this package is needed to support the user interface of applications installed through Winget.
The NuGet Twist
One of the standout features of this installation process is the inclusion of NuGet. Though primarily a .NET package provider, its role in the Winget installation is quite pivotal. Specifically, NuGet acts as the intermediary that fetches the Microsoft UI XAML dependency required for the VC++ Libraries V14.
While some users might bypass the intricacies and head straight into the installation, understanding these interconnections can be invaluable, especially when scripting Winget’s installation.
The PowerShell Script
Still not sure if I am 100% happy but I figure I might as well showcase some code as a result of going through the pain of getting Winget installed. The first 16 lines are not terribly exciting as I am doing some house keeping by setting variables and logging the install. Do note that line 3 contains the folder to log to and line 11 begins logging but the log name could be changed to your liking as well. Lines 14 and 15 define the latest release location for Winget but does not download it at this point.
You can see that lines 19 and 20 go and download both Winget but the Visual C++ libraries to the current working folder of the script.
Line 26 is especially troublesome, I wanted to use logic to check if the package provider was present before installing but the code would not install the NuGet package provider silently. The command used is silent and pay special attention to the “-Confirm:$false” parameter as it will silence the installation prompt.
The next bits of code work well to install the NuGet PowerShell module and configure the NuGet repository.
The Microsoft UI XAML dependency was a bit tricky because the installation is a three phase process. First the download of the package is needed using Get-Package. Next, the package is installed using the Install-Package command but that doesn’t install the application. A final step using Add-AppxPackage is used to install the dependency.
The VC++ V14 libraries can now be installed without issue.
And finally, the Winget MSIX bundle can be installed to complete the installation. On line 83 the script completes with a Stop-Transcript statement to turn off the logging.
I hope this code, article and video can help put together enough knowledge to make using Windows 10 with Winget a little less challenging. Feel free to copy modify the code as you see fit for your needs.
If you would like to see the code in action then have a look at the following YouTube video.
Installing Winget on Windows 10: A Comprehensive Guide – YouTube