Introduction
You may have heard of, or even already used PackageManagement (aka OneGet). Recently, I was reading the OneGet blog and OneGet in GitHub, and decided to give it a try by installing the Windows Management Framework 5.0 Preview April 2015. I found that PackageManagement provides a consistent user experience by exposing the same set of PowerShell Cmdlets for different flavors of software installation technologies, such as PowerShell modules, NuGet packages, MSI, MSU, etc. It’s indeed a unified package management framework. So I decided to write some Desired State Configuration (DSC) resources for some of the PackageManagement providers, which will hopefully make your life even easier.
Prerequisites:
• Windows Management Framework 5.0 Preview April 2015
PackageManagementProviderResource
As PackageManagement is a work-in-progress, I have started with the following two providers, since they are pretty stable already: PSModule and NuGet. I named the DSC module as PackageManagementProviderResource, containing the following DSC resources:
- PSModule is a DSC Resource that corresponds to the PSModule PackageManagement provider for managing PowerShell modules. It fetches modules from the PowerShell Gallery repository
- NuGetPackage is a DSC resource that corresponds to the NuGet PackageManagement provider for managing packages from the NuGet package source.
- PackageManagementSource is a DSC Resource that lets you register or unregister a package source on your computer.
The source code for the DSC resources is available in PowerShell Github. Also, it’s downloadable from the PowerShell Gallery.
Samples
Sample 1– Install a JQuery package from the NuGet source location
Below is the DSC configuration where I used the PackageManagementSource and NuGetPackage DSC resources to install JQuery 2.0.1 from Nguet.org.
Sample 2– Install a PowerShell Module, ‘xJea’ from the PowerShell gallery
You may have noticed, unlike the above sample, that there is no package resource registration here. That is because the ‘PSGallery’ was already registered when WMF 5.0 preview was installed. You can always run the Get-PackageSource cmdlet to find out what package sources have already been registered on your system.
Hope you enjoy trying it out.
Thanks
Jianyun Tao
PowerShell Team