Author Posts

April 12, 2016 at 7:24 am

If I have a PackageSource, specified with the PackageManagementSource resource from the PackageManagementProviderResource module, how do I use DSC to install a package from that source (not nuget, otherwise I'd use the NugetPackage resource)?

It seems odd that DSC doesn't have a modern way to install software packages.

April 12, 2016 at 7:56 am

If we are talking explicitly about DSC, your pull server acts as a repo for any client to pull matching packages from. In WMF5, you can setup this repo even if you wish to operate your LCM in push mode. Basically whenever the LCM receives a mof, it will check it's local paths for the module/version in question, and if it's missing it will download it from the defined location (if it exists).

You _cannot_ configure the LCM to simply use the NuGet or PackageManagementProviderResource, however. It's just not designed for that. Maybe one day now that MS is releasing modules that setup private galleries more easily? But not today.

April 12, 2016 at 8:19 am

So why did Microsoft create the PackageManagementProviderResource if it's not for use with DSC?

In a previous life, I used chef to install Windows applications from a private choco repo. If OneGet is the package manager to rule all package managers, how should I use DSC to ask OneGet to install an application from a private repo?

April 13, 2016 at 6:26 am

So – this is one way to do it. Compared to chef's chocolatey_package resource or Ansible's win_chocolatey module, this is seriously painful.

        Script InstallPackageManagementForDSC {
            SetScript = {Install-Module PackageManagementProviderResource -Force}
            TestScript = {(get-module -l -name PackageManagementProviderResource).Count -gt 0}
            GetScript = {@{}}
        }
        
        Script InstallChocoProvider {
            SetScript = {Get-PackageProvider -Name Chocolatey -ForceBootstrap}
            TestScript = {(Get-PackageProvider -name Chocolatey).Count -gt 0}
            GetScript = {@{}}
            DependsOn = '[Script]InstallPackageManagementForDSC'
        }

April 16, 2016 at 8:11 am

Yeah you're basically just running a script block and manually pulling what you want.

The PackageManagementResource actually contains the Nuget package. It's simply not meant for DSC, it's meant for PowerShell .... not all modules are DSC modules, after all.

DSC only really has a mechanism for pushing DSCResources, not "all" resources. If you're asking about a module in order to pull non-DSC resources into the mix (like chocolatey) you can always author a module for that. Heck in the script block you already started the code. But be aware it CAN'T be used for downloading DSC Resources (I might have been confusing your intent earlier in thinking you were trying to download DSC modules via the PSGallery ... that won't work).