RamblingCookieMonster / PSDeploy

Simple PowerShell based deployments
http://ramblingcookiemonster.github.io/PSDeploy-Take-Two/
MIT License
347 stars 69 forks source link

DependingOn not working as expected (ordering wrong) #101

Open csandfeld opened 6 years ago

csandfeld commented 6 years ago

Using DependingOn results in a deployment order that is completely different from what I expected.

Consider the following psdeploy.ps1 file:

Deploy A {

    By Task Setup {
        FromSource {
            'Setup'
        }
    }

    By Task One {
        FromSource {
            'One'
        }
        DependingOn Setup
    }

    By Task Three {
        FromSource {
            'Three'
        }
        DependingOn Two
    }

    By Task Five {
        FromSource {
            'Five'
        }
        DependingOn Four
    }

    By Task Four {
        FromSource {
            'Four'
        }
        DependingOn Three
    }

    By Task Two {
        FromSource {
            'Two'
        }
        DependingOn One
    }

    By Task Teardown {
        FromSource {
            'Teardown'
        }
        DependingOn One, Two, Three, Four, Five
    }

}

I would expect the order of execution to be:

But what I get is:

C:\test> Get-PSDeployment -Path .\test.dependencies.psdeploy.ps1 | Select DeploymentName

DeploymentName
--------------
A-Five
A-One
A-Three
A-Two
A-Four
A-Teardown
A-Setup
C:\test> Invoke-PSDeploy -Path .\test.dependencies.psdeploy.ps1 -Force
Five
One
Three
Two
Four
Teardown
Setup

Version used:

C:\test> Get-Module PSDeploy

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.2.1      PSDeploy                            {By, DependingOn, Deploy, FromSource...}
RamblingCookieMonster commented 6 years ago

Hiyo!

So it looks like we namespace the dependency name - try using A-One, A-Two and so forth as the items you are depending on.

I don't recall the specifics, but I think it was to avoid collisions. I might need to update docs, there's some info here, but at a quick glance didn't see in module docs.

Also, in that example... not sure why B wasn't namespaced. Will have to look at the code, might take a few days

Let me know how it turns out with the namespaced DependingOn bits!

Cheers!

csandfeld commented 6 years ago

Yup - using namespaced names works - thank you for your speedy reply

csandfeld commented 6 years ago

On another note ... is there a way to setup a task, to only run if specific tasks are used? In other words, if Invoke-PSDeploy is invoked without specifying the tag, the task does not run.

RamblingCookieMonster commented 6 years ago

Hi! Completely missed the follow-up, sorry about that!

Can you give a quick pseudocode example that you might expect to use if this was in place? Just the ability to use tags for Task deployment types? Just flipped through the code, and I explicitly avoided this for some reason - if you have any ideas on how to implement it, seems like it would handy!

csandfeld commented 6 years ago

No worries, and sorry for the late reply. Racking my brain to try and remember what that was all about, but comming up short.