Getting started with the new Windows package manager

Linux is a great environment to manage if you value automation and are comfortable with the command line and scripting. For example, working with Red Hat Enterprise Linux, I can use yum, a command line tool, to install and remove individual packages and groups of packages, and update packages already installed on my systems. PowerShell has added a lot of scripting power to Windows platform management, but until recently Windows lacked a key command-line utility: a package manager. But now, instead of having to use third-party package managers like Chocolatey, Windows developers and administrators have their own made-in-Redmond (native) tool to automate the process of installing software on their Windows machines. Its name is Windows Package Manager, but you can call it Winget. And it’s open source!

To learn more about Winget, I asked my colleague Jeffrey Hicks, who previously gave us an in-depth look at Windows Terminal, to do something similar for us with Winget. Jeffery is an IT veteran with nearly 30 years of experience, much of it as an IT infrastructure consultant specializing in Microsoft server technologies with a focus on automation and efficiency. He is a multi-year Microsoft MVP Award recipient. He now works as a freelance author, teacher and consultant. Jeff has taught and presented PowerShell and the benefits of automation to IT professionals around the world. He is the author and co-author of numerous books, written for numerous online sites and print publications, is an author of Plural sight and is a frequent speaker at technology conferences and user groups. His latest books are The PowerShell Practice Primer and PowerShell Scripting and Toolmaking. You can follow Jeff on Twitter and on his blog.

So without further ado, here’s Jeffrey:

Intensive package management course

If you’re an IT professional, you’ve probably spent part of your career installing software on end-user workstations. You can still find yourself doing this for your own office. In the Windows world, there are software solutions to help you manage this task at the enterprise level. But many places still have to handle this task the old fashioned way. This is where package management comes in.

Package management in the Linux world is given. You can find, install, upgrade, and remove software packages directly from a command prompt. The package manager queries one or more online sources:

The package manager can install the package, as well as generally any dependencies:

Fin

The package is a stand-alone set with the program and instructions on how to install it automatically without any user interaction. The package manager can show you what has been installed:

When the time comes, you can ask the package manager to check for updates and apply them. If necessary, he can also uninstall the package.

Microsoft has never had a true package manager for desktop clients. There are popular third-party tools like Chocolatey, but never anything complete from Microsoft. Until now.

Meet Winget

Microsoft has been working on a new command line based package manager for Windows called Fin. It is not a PowerShell tool but a real command line utility like ipconfig, although you can run Winget from a PowerShell prompt. From what I can tell while reading about this project, Microsoft’s target audience is developers who need a quick and easy way to install and manage software applications on their Windows 10 desktop (and soon 11).

Microsoft maintains an online repository of packages. The repository includes packages for Microsoft products like Microsoft Teams and Visual Studio Code, as well as popular apps like Dropbox and Google Chrome. In the future, Winget should also have access to the new Microsoft Store. For now, there is only one repository.

Winget has four main tasks:

  • Find packages
  • Install packages
  • Update packages
  • Uninstall packages

I will come back to these steps in a little more detail later.

Limits

Of course, IT pros are no different in their needs for managing desktop applications and packages, although I must stress that Winget is not designed to be a business-wide solution. ‘business. There are also no plans to deploy software packages to servers. In its current state, it is only suitable for interactive use on a local client machine.

The app doesn’t have a lot of scripting interface. You can easily write a batch file to install a bunch of packages, but that’s about it. You also cannot run the app on a remote PowerShell or even ssh session.

You will get this error:

There is an open issue on this issue, and hopefully at some point that won’t be a limitation, but unfortunately it is today.

And of course, this is a command line utility, not a PowerShell cmdlet. While you can run Winget in PowerShell, there is no object to mine. This is an early issue that came up with a very heated discussion that you can follow on this GitHub forum.

I’ll share a minor PowerShell workaround a bit later.

Winget installation

As of this writing, Winget is still technically in public preview. I think we’ll see an official release before the end of 2021. While there are some features that we may have to wait until the official release, Winget is stable enough that I’ve been using it for over a year.

Eventually, you should be able to install it from the Microsoft Store. This will be good because then you will get automatic updates. It’s technically possible to get Microsoft Store support today, but it requires additional steps that frankly aren’t worth the effort. Since I would expect you to ram the tires on your own, a manual installation should be fine.

You will need to be running at least Windows 10 1809. I had no problem installing it on current versions of Windows 11. Apparently there are workarounds to install it on Windows Server 2019, but I would ignore it until ‘That the remote Winget execution be resolved.

The installation requires some application installation packages, which should already be installed on most Windows 10 workstations. And finally, for now, you will need to install from a CMD prompt or Windows PowerShell 5.1. The installer package I’m going to get you to use is an msixbundle, which you can install using Add-AppxPackage. Unfortunately, PowerShell 7 is currently having an issue loading the Appx module. If you want to install from a prompt, it must be a CMD or Windows PowerShell prompt. Or you can just double click on the file after downloading it.

What are you downloading? Go to the project’s Github repository where you can get the latest version. Download the .msixbundle file:

Fin

You can double-click the file in Explorer to install it or use Add-AppxPackage in Windows PowerShell:

If you are missing any of the requirements, the installation should tell you. If you get an error regarding missing VCLibs files, you should be able to download the file from here. Install the file:

Then install the DesktopAppInstaller package. The whole process should only take a minute.

Keep in mind that installing from GitHub means Winget will not update automatically. You will need to manually install new versions as they become available. And oddly enough, there is no Winget package that you can install with Winget!

A final installation option is to use my WingetTools PowerShell module, which I will mention at the end of the article.

Acquire help

Once installed, you can simply type Winget using a PowerShell command or prompt:

Fin

As you can see the help is pretty straightforward. Personally, the most useful additional information is the URL of the home page:

Fin

But, it won’t get you where you think it will. The link takes you to the Github repository which contains the package manifests. Unless you create packages for Winget to install, this probably won’t be of much use to you.

Each Winget subcommand probably has additional help. Use -? to see him :

Wing features

Depending on the version, Winget may have additional experimental features. These are usually disabled by default:

As you can see, if you want to enable a feature, you need to configure the settings.

Winget configuration

Winget settings are stored in a JSON file. Although you can find community-created front-end tools. Otherwise, run Winget settings to open the file. If you have an associated application, such as Visual Studio Code, the file will open in it. Otherwise, you will have to choose another app like Notepad. You will see something like this:

I like that the Winget team includes a link where you can get more information on what you can configure. I’ll let you read their documentation, but point out some of the settings that I think you’ll want to change. Here is a config file that I will be using:

Since this is a JSON file, watch your box. If you are using Visual Studio code, it will know how to use the schema and give you help from Intellisense. When you save the file, the changes take effect immediately.

In the second and final part of this series, we will see how to find packages, install them, uninstall them, and update them.

Featured Image: Shutterstock


Publication displays:
9


Ezoicreport this ad



Source link

Comments are closed.