Windows 10 PackageManagement

22 Mar 2016

chocolatey how to package management powershell windows

Windows 10 comes with nice feature - OneGet - Manager of Package managers. It simplifies way of installing software on a PC and what is more important - it allows to make it scriptable. I'm big fan of Chocolatey so I was glad to learn that Microsoft took care of integrating it with OneGet. Basic info can be found in Scott Hanselman blog post Apt-Get for Windows - OneGet and Chocolatey on Windows 10 and on Microsoft TechNet blog post Introducing PackageManagement in Windows 10.

WARNING
Chocolatey provider is broken and at the moment it only downloads packages to C:\Chocolatey\lib folder, but doesn't install them properly
As a workaround you can use following script (run it elevated powershell console)

To get started first configure Chocolatey as a package provider

Get-PackageProvider -Name Chocolatey
Set-PackageSource -Name Chocolatey -Trusted

Example

PS C:\Users\Mateusz> Get-PackageProvider -Name Chocolatey

The provider 'chocolatey v2.8.5.130' is not installed.
chocolatey may be manually downloaded from https://az818661.vo.msecnd.net/providers/ChocolateyPrototype-2.8.5.130.exe and installed.
Would you like PackageManagement to automatically download and install 'chocolatey' now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

Name                     Version          DynamicOptions
----                     -------          --------------
Chocolatey               2.8.5.130        SkipDependencies, ContinueOnFailure, ...

PS C:\Users\Mateusz> Set-PackageSource -Name Chocolatey -Trusted

Name                             ProviderName     IsTrusted  IsRegistered IsValidated  Location
----                             ------------     ---------  ------------ -----------  --------
chocolatey                       Chocolatey       True       True         True         http://chocolatey.org/api/v2/

Check that Chocolatey is installed with command

Get-PackageProvider

Example

PS C:\Users\Mateusz> Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
Chocolatey               2.8.5.130        SkipDependencies, ContinueOnFailure, ...
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, ...

As a test install git with command

Find-Package git
Install-Package git

Note:
You may be prompted to install NuGet package provider

Example

PS C:\Users\Mateusz> Find-Package git

The provider 'nuget v2.8.5.202' is not installed.
nuget may be manually downloaded from https://az818661.vo.msecnd.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.202.dll and installed.
Would you like PackageManagement to automatically download and install 'nuget' now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

Name                           Version          Source                         Summary
----                           -------          ------                         -------
git                            2.7.4            chocolatey                     Git (for Windows) – Fast Version Control

PS C:\Users\Mateusz> Install-Package git

Name                           Version          Source                         Summary
----                           -------          ------                         -------
git                            2.7.4            chocolatey                     Git (for Windows) – Fast Version Control

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.