-
-
Notifications
You must be signed in to change notification settings - Fork 59
Portable Build Scripts
It is possible and sometimes expected to have a copy of Invoke-Build tools kept together with build scripts. This makes the build tool set portable, i.e. build scripts can be invoked on any machine without Invoke-Build installed.
Another reason to keep a copy of Invoke-Build with scripts is use of multiple build engine versions, potentially incompatible. Existing build scripts do not have to be upgraded for a newer version, they may continue to use the old copy.
Build scripts which do not call Invoke-Build.ps1 and Build-Parallel.ps1 are
already portable. Otherwise in order to be portable build scripts should follow
the simple rule: always invoke tools by the predefined aliases Invoke-Build
and Build-Parallel
, i.e. avoid using script names with extensions.
These aliases are predefined by the engine and associated with exactly those scripts that are currently running. Namely:
-
Invoke-Build
is an alias of the currently running script Invoke-Build.ps1; -
Build-Parallel
is an alias of Build-Parallel.ps1 in the same directory. -
Resolve-MSBuild
is an alias of Resolve-MSBuild.ps1 in the same directory.
Thus, nested calls of Invoke-Build
from tasks invoke Invoke-Build.ps1 which
is currently running, e.g. which is kept together with the scripts. Compare:
calls to Invoke-Build.ps1, i.e. with the extension, may fail because either
Invoke-Build.ps1 is not in the path on the machine or it is incompatible.
Only top level commands may invoke builds as Invoke-Build.ps1 (assuming it is in the path) or FullOrRelativePath\Invoke-Build.ps1 (assuming it is there).
- Concepts
- Script Tutorial
- Incremental Tasks
- Partial Incremental Tasks
- How Build Works
- Special Variables
- Build Failures
- Build Analysis
- Parallel Builds
- Persistent Builds
- Portable Build Scripts
- Using for Test Automation
- Debugging Tips
- VSCode Tips
Helpers
- Invoke Task from VSCode
- Generate VSCode Tasks
- Invoke Task from ISE
- Resolve MSBuild
- Show Build Trees
- Show Build Graph
- Argument Completers
- Invoke-Build.template
Appendix