Skip to content

support 'legacy' buildscripts (job -safe) #203

Answered by nightroman
mwallner asked this question in Q&A
Discussion options

You must be logged in to vote

I am glad to know that safe jobs/tasks are used not just by me.
I think you are thinking correctly. Your idea with a few tweaks:

legacy.build.ps1

task IWork {
    'I am working.'
}

task IFail {
    throw 'I failed.'
}

task Something (job IWork), (job IFail -Safe), {
    'Something is working.'
}

ib-legacy-hack.psm1

function job {
    param(
        [string]$name,
        [switch]$safe
    )
    if ($safe) {
        "?$name"
    }
    else {
        $name
    }
}

Test-1.ps1

Import-Module $PSScriptRoot\ib-legacy-hack.psm1
Invoke-Build -File $PSScriptRoot\legacy.build.ps1 -Task Something

Output:

Build Something C:\tmp\_220629_qs-ib-203\legacy.build.ps1
Task /Something/IWork
I am working.
D…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mwallner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants