-
-
Notifications
You must be signed in to change notification settings - Fork 61
Portable Build Scripts
It is possible and even expected in some cases to have a copy of Invoke-Build tools kept together with build scripts (Invoke-Build.ps1 is often enough). This makes the build tool set portable, i.e. build scripts can be invoked on any machine without Invoke-Build in the path.
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 Invoke-Builds.ps1 are
already portable. Otherwise in order to be portable build scripts should follow
one simple rule: invoke tools by aliases Invoke-Build
or Invoke-Builds
, not
by 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; -
Invoke-Builds
is an alias of the script Invoke-Builds.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 should 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