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

Script block as File (new feature) #78

Closed
nightroman opened this issue Jul 3, 2017 · 2 comments
Closed

Script block as File (new feature) #78

nightroman opened this issue Jul 3, 2017 · 2 comments

Comments

@nightroman
Copy link
Owner

Having to have a build script file is a nuisance in some scenarios. It would be
useful to define, assemble, import, and invoke tasks using just script blocks.

The required change is simple and backward compatible. The parameter File
accepts either a script block (new) or a script path (usual).

Example of a script block used as the parameter File:

    Invoke-Build <tasks> {
        ...
    }

The script block either defines the whole build itself or assembles it from
external task scripts. It is possible to alter or redefine tasks, add new
tasks, and set build blocks on the fly.

What are the conventional $BuildFile and $BuildRoot? $BuildFile is
informational and not so important. But $BuildRoot is very important,
it is maintained as the current location for build blocks.

One possible convention:

  • $BuildFile is the calling script.
  • $BuildRoot is its directory.

Note that $BuildFile may be null in cases like jobs, calls from .NET, "run
selection" in some IDE with PowerShell hosting, etc. In such cases we will
just use the current location as the default $BuildRoot.

In any case, if the default $BuildRoot is not suitable then it may be set to
a required full path explicitly in a build code (documented feature).

@daviwil
Copy link

daviwil commented Jul 7, 2017

This seems really helpful actually, I could include a check for Invoke-Build in my build script and install it from the Gallery before running Invoke-Build with my task definitions, all without needing 2 separate scripts.

@nightroman
Copy link
Owner Author

@daviwil
Yes, this is the idea.
repo/Tasks/Inline contains some sample use cases.

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

No branches or pull requests

2 participants