-
-
Notifications
You must be signed in to change notification settings - Fork 59
Comparison with MSBuild
MSBuild is yet another build automation tool, part of the .NET Framework. Invoke-Build is designed to be very similar. Of course, their scripts use different languages (PowerShell and XML) and different built-in and external tools. But build flow, script structure, and main concepts are mostly the same.
MSBuild Invoke-Build
------- ------------
Default build script A single *.build.ps1 or .build.ps1
InitialTargets Whatever a build script invokes
DefaultTargets The . or the first added task
Properties Script/environment variables
Import Dot-source or invoke
Target Task
Condition -If
Inputs, Outputs -Inputs -Outputs [-Partial]
DependsOnTargets -Jobs, referenced tasks
Tasks -Jobs, script blocks
AfterTargets, BeforeTargets -After, -Before
MSBuild targets consist of calls to build-in or external tools. Invoke-Build
tasks consist of PowerShell script blocks. Unlike MSBuild, Invoke-Build does
not provide numerous tools for scripts, PowerShell has enough tools. Still,
some helpers are provided, like use
, exec
, assert
, property
.
Invoke-Build task jobs combine two MSBuild features: referenced targets and own
target tasks. The parameter Jobs
is a list of task references (analogue of
DependsOnTargets
) and script blocks (analogue of MSBuild tasks). Thus, jobs
define classic MSBuild scenarios (referenced tasks first, own scripts second)
and new scenarios with referenced tasks after or even between script jobs.
Invoke-Build "properties" are usual PowerShell script variables and parameters,
just like MSBuild properties defined in XML scripts (variables) and properties
that come from command lines (parameters). MSBuild also deals with environment
variables using the same syntax. In contrast, Invoke-Build scripts should
either use them explicitly as $env:Name
or get by the helper property
.
MSBuild lets to ignore some errors and perform actions on errors. Invoke-Build also lets to deal with errors: some tasks are allowed to fail without breaking the build and then downstream tasks can analyse these errors.
Invoke-Build allows definition of new tasks with specific features and new
parameters, not necessarily designed for build scenarios. E.g. check
for
check-lists, repeat
for schedules, test
for testing, and etc. MSBuild
presumably does not directly support definition of new targets.
- 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