Install your applications with winget
Tags: commandline, windows, tooling, winget
Published: 2021-05-26 06:56:06

---
title: Install your applications with winget
published: true
date: 2021-05-26 00:00:00 UTC
tags: commandline, windows, tooling, winget
canonical_url: https://techwatching.dev/posts/winget-import
---

## About Windows Package Manager

You probably have already heard of the new [Windows Package Manager](https://docs.microsoft.com/en-us/windows/package-manager/) and its command line tool `winget` that allows you to automate installing and upgrading software on your Windows 10 computer.

With winget you can install an application very easily simply by executing in your terminal a command like this one which installs powertoys:

```
winget install powertoys

```

Currently Windows Package Manager only offer basic features and has far less packages compared to other package managers like [Chocolatey](https://chocolatey.org/). However, even if `winget` is still in its early days, there are some promising features that make it a tool to consider when setting up a Windows 10 machine.

## Installing Microsoft Store applications

First, winget is able to install Microsoft Store applications. Most of the software you use as a developer probably does not come from Microsoft Store, but there are still some applications that it is handy to get from it. For instance the new Windows Terminal is available as a Microsoft Store application. As far as I know, apart from `winget` there is no other easy way to install a Microsoft Store application from the command line. With `winget` you can just do: `winget install Microsoft.WindowsTerminal -s msstore` to install the new WindowsTerminal application from Microsoft Store.

📌 Please note that at the time of writing, installing store applications from winget is an experimental feature that you have to enable in `winget settings` and that only a subset of Microsoft Store applications can be installed.  
 ![](https://techwatching.dev/posts/images/winget_import_1.png)

## Installing several packages with the import command

Second, winget has an `import` command that allow to install all the package specified in a json file you pass in parameter. It means that instead of writing a script with many install commands for each of the package you want to install, you can write a `package.json` file that will contain all the packages you want to install, their version, the source of the package (place to find them, msstore for Microsoft Store applications), ... and you will be able to install the software with one command: `winget import packages.json`

Here is an example of such a file:

```
{
	"$schema" : "https://aka.ms/winget-packages.schema.2.0.json",
	"CreationDate" : "2021-05-23T14:41:38.200-00:00",
	"Sources" : 
	[
		{
			"Packages" : 
			[
				{
					"PackageIdentifier" : "Microsoft.Whiteboard"
				},
				{
					"PackageIdentifier" : "Microsoft.WindowsTerminal"	
				}
			],
			"SourceDetails" : 
			{
				"Argument" : "https://winget.azureedge.net/msstore",
				"Identifier" : "Microsoft.Winget.MSStore.Source_8wekyb3d8bbwe",
				"Name" : "msstore",
				"Type" : "Microsoft.PreIndexed.Package"
			}
		},
		{
			"Packages" : 
			[
				{
					"PackageIdentifier": "Microsoft.AzureCLI"
				},
				{
					"PackageIdentifier" : "Microsoft.PowerToys"
				}
			],
			"SourceDetails" : 
			{
				"Argument" : "https://winget.azureedge.net/cache",
				"Identifier" : "Microsoft.Winget.Source_8wekyb3d8bbwe",
				"Name" : "winget",
				"Type" : "Microsoft.PreIndexed.Package"
			}
		}
	],
	"WinGetVersion" : "0.4.11391"
}

```

It contains packages from Microsoft Store and packages from `winget` package repository hence the 2 arrays of packages (one by each source).

📌 You can easily edit this json in vscode with autocompletion thanks to the link to the json `schema` at the beginning of the json.

Import is great but there are still things missing like the ability to silently install the applications which is possible with the install command.

## Final thoughts

Chocolatey will continue to be my main package manager for now: on the one hand for the number of packages available and on the other hand for being able to specify some parameters for a package installation (like the workload and components to install for Visual Studio 2019). Yet, `winget` will be part of my toolbox as well to install some packages (including Microsoft Store applications) and I expect it to continue to get better and better.