Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/tutorial-advanced/outputs-and-artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ Task Package -Depends Build {
}
```

**Important:** These variables are **only** accessible within the same `Invoke-psake` call. They **cannot** be accessed by the calling script.
**Important:** These variables live in the psake **module scope** and persist across `Invoke-psake` calls — they are not automatically reset between calls. They cannot be accessed from the calling script as regular PowerShell variables.

> **Gotcha:** If a variable is declared inside a `Properties` block, that block re-runs on every `Invoke-psake` call and will **silently overwrite** whatever value the previous call left behind. Only variables set inside task bodies (not `Properties`) survive intact between calls.

**When to use:** For passing data between tasks within the same build execution.

Expand Down Expand Up @@ -545,7 +547,7 @@ steps:

1. **Use JSON/YAML output files** - This is the primary recommended approach for returning data
2. **Always check exit codes** - They remain the primary success/failure indicator
3. **Use `$script:` variables for inter-task communication** - But understand they're not accessible outside psake
3. **Use `$script:` variables for inter-task communication** - They persist in the psake module scope across calls; they are not accessible from the calling script as regular variables
4. **Avoid Write-Host/Write-Output** for structured data - Use files instead
5. **Document your output schema** - So consumers know what to expect
6. **Handle failures gracefully** - Ensure output files contain meaningful error information
Expand Down
2 changes: 2 additions & 0 deletions docs/tutorial-advanced/variable-referencing.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@ In case you create a variable with script scope, the variable is kept inside the
psake module. This means, that if you run Invoke-psake again, the variable is
available. That’s why variables with script scope should be used carefully.
Consider them as global variables accessible for all scripts running in psake.

> **Gotcha:** If a `$script:` variable is declared inside a `Properties` block, that block re-runs on every `Invoke-psake` call and will **silently overwrite** whatever value the previous call left behind. Only variables set inside task bodies (not `Properties`) survive intact between calls.
Loading