Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding included tasks #182

Open
samegutt opened this issue May 22, 2016 · 1 comment
Open

Overriding included tasks #182

samegutt opened this issue May 22, 2016 · 1 comment
Labels

Comments

@samegutt
Copy link

Given the two scripts CommonTasks.ps1

Task Build -depends Clean, Compile

Task Clean{ }

Task Compile { }

and MyTasks.ps1

Include ".\CommonTasks.ps1"

task default -depends Build

task MyClean -alias "Clean" { }

The task MyClean effectively overrides the task Clean with its alias, giving the following output:

C:\> Invoke-psake .\MyTasks.ps1
Executing MyClean
Executing Compile

Build Succeeded!

Q: It this by design? Or is this unintentional? I am creating some common build steps for the project I work for, and some of the modules needs some customisation to the build flow. Using the -alias parameter I get the functionality I need, but the solution has some apparent smells.

Suggestion: An -override parameter would make the purpose of MyCleanvery clear.

@UberDoodles
Copy link
Contributor

@samegutt

I just posted a reply to #298, and I realised my reply might also apply here. Interestingly, that issue suggested the ability to merge tasks, rather than override them.

Generally, I don't define dependencies for any tasks which have an action. When I want to chain tasks together; I create a separate task for that purpose. It gives you more flexibility to run exactly what you want to.

Would that help you achieve what you are trying to do?

There might be other use cases where being able to override (or merge) tasks is useful though, and I like your suggestion about adding an -override parameter to make it clear what is going to happen to the two task definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants