DSC DependsOn not working during initial run

Hi Guys

I’m busy testing some DSC Configs and it looks like the DependsOn property is not being adhered to during a run of DSC.

My Composite Resource looks like this:

  
        cChocoPackageInstaller $Package1
        {
            Name                 = $("$Package1_" + $Package1Version)
            Version              = $Package1Version
            Source               = 'nexusrepo'
            chocoParams          = "--pre --force"
            Params               = $Params
            PsDscRunAsCredential = $DomainCredentials

        }
        cChocoPackageInstaller $Package2
        {
            Name                 = $("$Package2_" + $Package2Version)
            Version              = $Package2Version
            Source               = 'nexusrepo'
            DependsOn            = "[cChocoPackageInstaller]$Package1"
            chocoParams          = "--pre --force"
            Params               = $Params
            PsDscRunAsCredential = $DomainCredentials 

Does DSC do a Test-TargetResource in between applying resources?

Thanks for the help.

DependsOn and composites get a little weird. That’s especially true when you’re non-deterministic, as when using variables for resource names. Composites can be a wee bit delicate in some ways.

You could enable a trace, and then check the Debug logs for DSC on the node. That’d give you more detail about what’s happening and when it’s happening.

Thanks Don

I enabled debugging and stepped through the deployment it can’t find anywhere that DependsOn is used before the next package is executed.

My thinking is that DependsOn doesn’t care if a resource is in a valid state it only ensures that the resources are executed in the correct order.

How does DSC then stop if one resource fails?

In my experience, DependsOn really do care if a required resource complete successfully. In one of our configuration, SQL didn’t even tr to install because one of it’s dependency had an error while installing.

@Syl you might be correct what I’m thinking then is, when DSC does a run it will only stop if a specific resource’s “Set-TargetResource” throws an error. It doesn’t do a “Test-TargetResource” directly after it has completed a “Set-TargetResource”

I’ll try and do a bit more investigation into this today.