GithubHelp home page GithubHelp logo

Parallel builds scope about invoke-build HOT 1 CLOSED

nightroman avatar nightroman commented on May 27, 2024
Parallel builds scope

from invoke-build.

Comments (1)

nightroman avatar nightroman commented on May 27, 2024

Yes, this by design, and rather by PowerShell design than Invoke-Build.
Invoke-Build just runs parallel builds in separate runspaces created by
[PowerShell]::Create(). Forget about Invoke-Build for a moment and try to
invoke some code using this way. You will see that nothing from the current
scope is propagated to a new runspace.

Alas, with the power of parallel processing come some rules and limitations.

What you can do. In your simple case use parameters in order to pass data to
parallel builds explicitly. That is declare the parameter in the build script:

    # build.ps1
    
    param($Foo)

    Task Foo {
        $Foo
    }

and invoke it with passing the variable $Foo as parameter:

    . .\script.ps1

    Invoke-Builds @(@{File=".\build.ps1"; Task='Foo'; Foo=$Foo})

Similarly, pass other required data as parameters. If you have too many
items, consider using an object with properties or a hashtable.

What about scope functions? With parallel processing in mind you have to
redesign something anyway. It is up to you how, there are many ways. For
example, put shared functions to a module, or another dot-sourced script,
then import them to a calling script and to a build script, too. Or define
and use functions as script blocks and pass them to a build script as data
via parameters (not neat perhaps but handy in some cases).

from invoke-build.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.