Comments (1)
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)
- Is it possible to change the name of the build in Build-Parallel? HOT 7
- Invoke-Build with `Set-StrictMode -Version [123]` Results in Exception HOT 28
- Improve `exec -echo` ANSI rendering
- Write-Build: render lines separately if ANSI.
- Amend output on task errors.
- Reusing or sharing tasks HOT 5
- ib.cmd ? ignores a specified file
- vscode outline view: no symbols found in document HOT 2
- Different module and package versions HOT 2
- Parallel execution based on dependency tree HOT 2
- invoke-build discovery fails in powershell container HOT 3
- Please consider adding -Computername and -Session parameter to Task HOT 8
- GitHub action output is not colored
- Color and formatting text in Azure DevOps Pipelines HOT 8
- Use-BuildEnv should make parameters mandatory
- Invoke-BuildExec spitting out service principal secret as current directory HOT 6
- Exec doesn't work well with forward slash arguments HOT 7
- Use `[System.Management.Automation.Cmdlet]::CommonParameters` to get the names of all common parameters HOT 3
- Task condition does not work HOT 8
- Build-Parallel writes only to Output stream HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from invoke-build.