-
-
Notifications
You must be signed in to change notification settings - Fork 59
Comparison with MSBuild
Invoke-Build is designed to be conceptually similar to MSBuild. Of course, they use different languages, PowerShell and XML, and different tools. But build concepts and script structure are almost the same.
MSBuild Invoke-Build
------- ------------
Default project *proj Default script *.build.ps1
InitialTargets The top level script code
DefaultTargets The . or the first 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 provides the tools. Still,
there are some helpers like use
, exec
, assert
, equals
, 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