Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

Downloads:

35,621

Downloads of v 5.12.1:

132

Last Update:

27 Nov 2024

Package Maintainer(s):

Software Author(s):

  • Roman Kuzmin

Tags:

build powershell module cross-platform foss

Invoke-Build

  • 1
  • 2
  • 3

5.12.1 | Updated: 27 Nov 2024

Downloads:

35,621

Downloads of v 5.12.1:

132

Maintainer(s):

Software Author(s):

  • Roman Kuzmin

Invoke-Build 5.12.1

Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by Roman Kuzmin. The inclusion of Roman Kuzmin trademark(s), if any, upon this webpage is solely to identify Roman Kuzmin goods or services and not for commercial purposes.

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install Invoke-Build, run the following command from the command line or from PowerShell:

>

To upgrade Invoke-Build, run the following command from the command line or from PowerShell:

>

To uninstall Invoke-Build, run the following command from the command line or from PowerShell:

>

Deployment Method:

NOTE

This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)


2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade invoke-build -y --source="'INTERNAL REPO URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade invoke-build -y --source="'INTERNAL REPO URL'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Install invoke-build
  win_chocolatey:
    name: invoke-build
    version: '5.12.1'
    source: INTERNAL REPO URL
    state: present

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'invoke-build' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '5.12.1'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller invoke-build
{
    Name     = "invoke-build"
    Version  = "5.12.1"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'invoke-build':
  ensure   => '5.12.1',
  provider => 'chocolatey',
  source   => 'INTERNAL REPO URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved by moderator Windos on 03 Dec 2024.

Description

Invoke-Build is a build and test automation tool which invokes tasks defined in PowerShell v2.0+ scripts. It is similar to psake but arguably easier to use and more powerful. It is complete, bug free, well covered by tests.

Features

  • Incremental tasks with effectively processed inputs and outputs.
  • Persistent builds which can be resumed after interruptions.
  • Parallel builds in separate workspaces with common stats.
  • Batch invocation of tests composed as tasks.
  • Ability to define new classes of tasks.

Invoke-Build can invoke the current task from a build script being composed in ISE and VSCode, see Invoke-TaskFromISE.ps1 and Invoke-TaskFromVSCode.ps1.

Invoke-Build can be used as the task runner in VSCode with tasks maintained in a PowerShell build script instead of tasks.json, see New-VSCodeTask.ps1.

Invoke-Build v3.0.1 is cross-platform with PowerShell v6.0.0-alpha.

Notes

  • This package includes Invoke-TaskFromISE, Invoke-TaskFromVSCode, New-VSCodeTask and Invoke-Build.ArgumentCompleters supportive scripts. To setup launch profile in VSCode for build.ps1 files, use the following script path in launch.json:
    "script": "${env:ChocolateyInstall}/lib/invoke-build/tools/Invoke-TaskFromVSCode.ps1"
    
  • Its recommended to include the following in your PowerShell $PROFILE:
    sal ib Invoke-Build
    & $env:ChocolateyInstall\lib\invoke-build\tools\Invoke-Build.ArgumentCompleters.ps1
    

tools\chocolateyInstall.ps1
$toolsDir = Split-Path $MyInvocation.MyCommand.Definition
$moduleName = 'InvokeBuild'

Write-Host "Installing module $moduleName to $Env:ProgramFiles\WindowsPowerShell\Modules"
$destination = "$Env:ProgramFiles\WindowsPowerShell\Modules\$moduleName\"
if ($PSVersionTable.PSVersion.Major -lt 5)
{
    $source = "$toolsDir\$moduleName\*\*"
} else {
    $source = "$toolsDir\$moduleName\*"
}

# Copy-Item results differ depending on if destination exists or not
if (-not (Test-Path $destination)) {
    mkdir $destination | Out-Null
}
cp $source $destination -Force -Recurse
tools\chocolateyUninstall.ps1
$moduleName = 'InvokeBuild'

Write-Host "Uninstalling all versions of module $moduleName"

if (!(Test-Path $Env:ProgramFiles\WindowsPowerShell\Modules\$moduleName)) {
    Write-Host "Module not found, it is uninstalled some other way"
    return
}
rm $Env:ProgramFiles\WindowsPowerShell\Modules\$moduleName -Force -Recurse
Write-Host "Module $moduleName uninstalled"
tools\Invoke-Build.ArgumentCompleters.ps1
<#PSScriptInfo
.VERSION 1.0.4
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.GUID 78b68f80-80c5-4cc1-9ded-e2ae165a9cbd
.TAGS Invoke-Build, TabExpansion2, Register-ArgumentCompleter
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>

<#
.Synopsis
	Argument completers for Invoke-Build parameters.

.Description
	The script registers Invoke-Build completers for parameters Task and File.

	Completers can be used with:

	* PowerShell v5 native Register-ArgumentCompleter
	Simply invoke Invoke-Build.ArgumentCompleters.ps1, e.g. in a profile.

	* TabExpansion2.ps1 https://www.powershellgallery.com/packages/TabExpansion2
	Put Invoke-Build.ArgumentCompleters.ps1 to the path in order to be loaded
	automatically on the first completion. Or invoke after TabExpansion2.ps1,
	e.g. in a profile.
#>

Register-ArgumentCompleter -CommandName Invoke-Build.ps1 -ParameterName Task -ScriptBlock {
	param($commandName, $parameterName, $wordToComplete, $commandAst, $boundParameters)

	(Invoke-Build -Task ?? -File ($boundParameters['File'])).get_Keys() -like "$wordToComplete*" | .{process{
		New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_
	}}
}

Register-ArgumentCompleter -CommandName Invoke-Build.ps1 -ParameterName File -ScriptBlock {
	param($commandName, $parameterName, $wordToComplete, $commandAst, $boundParameters)

	Get-ChildItem -Directory -Name "$wordToComplete*" | .{process{
		New-Object System.Management.Automation.CompletionResult $_, $_, 'ProviderContainer', $_
	}}

	if (!($boundParameters['Task'] -eq '**')) {
		Get-ChildItem -File -Name "$wordToComplete*.ps1" | .{process{
			New-Object System.Management.Automation.CompletionResult $_, $_, 'Command', $_
		}}
	}
}
tools\Invoke-TaskFromISE.ps1
<#PSScriptInfo
.VERSION 1.0.5
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.TAGS Invoke, Task, Invoke-Build, ISE
.GUID 713b2e68-8b62-40f5-99cb-07c6952abca6
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>

<#
.Synopsis
	Invokes the current task from PowerShell ISE by Invoke-Build.ps1

.Description
	This script invokes the current task from the build script being edited in
	PowerShell ISE. It is invoked either in ISE or in PowerShell console.

	Invoke-Build.ps1 is searched in the directory of Invoke-TaskFromISE.ps1
	and then in the path.

	The current task is the task at the caret line or above. If none is found
	then the default task is invoked. The script is saved if it is modified.

	If the build fails when the task is invoked in ISE and the error location
	is in the same build script then the caret is moved to the error position.

	This script may be called directly from the console pane. But it is easier
	to associate it with key shortcuts. For example, in order to invoke it by
	Ctrl+Shift+T and Ctrl+Shift+B open the ISE profile:

		C:\Users\...\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

	and add menu commands and shortcuts:

		# Invoke task in ISE by Invoke-Build.ps1
		$null = $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(
		'Invoke Task in ISE', {Invoke-TaskFromISE.ps1}, 'Ctrl+Shift+T')

		# Invoke task in console by Invoke-Build.ps1
		$null = $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(
		'Invoke Task in Console', {Invoke-TaskFromISE.ps1 -Console}, 'Ctrl+Shift+B')

	These commands assume that Invoke-TaskFromISE.ps1 is in the path.
	If this is not the case then specify the full script path there.

.Parameter Console
		Tells to invoke the current task in a new PowerShell console.
#>

param(
	[Parameter()]
	[switch]$Console
)

$ErrorActionPreference = 1

$private:ib = "$(Split-Path $MyInvocation.MyCommand.Path)\Invoke-Build.ps1"
if (!(Test-Path -LiteralPath $ib)) {
	$ib = 'Invoke-Build'
}

$private:_Console = $Console
Remove-Variable Console

$private:file = $psISE.CurrentFile
if (!$file) {Write-Error "There is not a current file."}
if ($file.IsUntitled) {Write-Error "Cannot invoke for Untitled files, please save the file."}

$private:path = $file.FullPath
if ($path -notlike '*.ps1') {Write-Error "The current file must be '*.ps1'."}

if (!$file.IsSaved) {
	$file.Save()
}

$private:task = '.'
$private:editor = $file.Editor
$private:line = $editor.CaretLine
foreach($private:t in (& $ib ?? $path).get_Values()) {
	if ($t.InvocationInfo.ScriptName -ne $path) {continue}
	if ($t.InvocationInfo.ScriptLineNumber -gt $line) {break}
	$task = $t.Name
}

if ($_Console) {
	Start-Process PowerShell.exe ("-NoExit -NoProfile -ExecutionPolicy Bypass & '{0}' '{1}' '{2}'" -f @(
		$ib.Replace("'", "''")
		$task.Replace("'", "''").Replace('"', '\"')
		$path.Replace("'", "''")
	))
	return
}

try {
	& $ib $task $path
}
catch {
	$ii = $_.InvocationInfo
	if ($ii.ScriptName -eq $path) {
		$editor.SetCaretPosition($ii.ScriptLineNumber, $ii.OffsetInLine)
	}
	throw
}
tools\Invoke-TaskFromVSCode.ps1
<#PSScriptInfo
.VERSION 1.0.8
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.TAGS Invoke-Build, Task, VSCode
.GUID 1dcf7c94-b68d-4fb7-9e2b-886889b6c42e
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>

<#
.Synopsis
	Invokes the current Invoke-Build task from VSCode

.Description
	This script invokes the current task from the build script in VSCode.

	Requires:
	- Invoke-Build
	- VSCode PowerShell

	How to use:
	https://github.com/nightroman/Invoke-Build/wiki/Invoke-Task-from-VSCode

.Parameter Console
		Tells to invoke the task in an external console.

.Link
	https://github.com/nightroman/Invoke-Build/wiki/Invoke-Task-from-VSCode
#>

param(
	[Parameter()]
	[switch]$Console
)

$ErrorActionPreference = 1
try {

$private:file = $null
try {
	$private:context = $psEditor.GetEditorContext()
	$file = $context.CurrentFile
}
catch {}
if (!$file) {throw 'Cannot get the current file.'}

# save if modified, #118
if ($psEditor.EditorServicesVersion -ge [version]'1.6') {
	$file.Save()
}

$private:_Console = $Console
Remove-Variable Console

$private:path = $file.Path
if ($path -notlike '*.ps1') {throw "The current file must be '*.ps1'."}

$private:task = '.'
$private:line = $context.CursorPosition.Line
foreach($private:t in (Invoke-Build ?? $path).get_Values()) {
	if ($t.InvocationInfo.ScriptName -ne $path) {continue}
	if ($t.InvocationInfo.ScriptLineNumber -gt $line) {break}
	$task = $t.Name
}

if ($_Console) {
	$command = "Invoke-Build '$($task.Replace("'", "''"))' '$($path.Replace("'", "''"))'"
	$encoded = [Convert]::ToBase64String(([System.Text.Encoding]::Unicode.GetBytes($command)))
	Start-Process powershell.exe "-NoExit -NoProfile -ExecutionPolicy Bypass -EncodedCommand $encoded"
}
else {
	Invoke-Build $task $path
}

} catch {if ($_.InvocationInfo.ScriptName -like '*Invoke-TaskFromVSCode.ps1') {$PSCmdlet.ThrowTerminatingError($_)} throw}
tools\InvokeBuild\5.12.1\about_InvokeBuild.help.txt
TOPIC
    about_InvokeBuild

SHORT DESCRIPTION
    Build and test automation in PowerShell

LONG DESCRIPTION
    The module provides the following commands:

        Invoke-Build
            The alias of Invoke-Build.ps1
            It invokes build scripts, this is the build engine.

        Build-Checkpoint
            The alias of Build-Checkpoint.ps1
            It invokes persistent builds using the engine.

        Build-Parallel
            The alias of Build-Parallel.ps1
            It invokes parallel builds using the engine.

    Import the installed module:

        Import-Module InvokeBuild

    Or import from the specified location:

        Import-Module <path>\InvokeBuild.psd1

    Get help for the engine:

        help <path>\Invoke-Build.ps1 -full

    Get help for build commands:

        . <path>\Invoke-Build.ps1
        help task -full
        help exec -full
        ...

    The package contains the build engine with a few helpers, all you need
    for running build scripts. There are various related tools, see README.
tools\InvokeBuild\5.12.1\Build-Checkpoint.ps1
<#
Copyright (c) Roman Kuzmin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
#>

#.ExternalHelp Help.xml
[CmdletBinding(DefaultParameterSetName='Default')]
param(
	[Parameter(Position=0, Mandatory=1)]
	[string]$Checkpoint
	,
	[Parameter(Position=1)]
	[hashtable]$Build
	,
	[switch]$Preserve
	,
	[Parameter(ParameterSetName='Resume', Mandatory=1)]
	[switch]$Resume
	,
	[Parameter(ParameterSetName='Auto', Mandatory=1)]
	[switch]$Auto
)

$ErrorActionPreference = 1
try {

$Checkpoint = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($Checkpoint)

$Build = if ($Build) {@{} + $Build} else {@{}}
if ($Build['WhatIf']) {throw 'WhatIf is not supported.'}

${*checkpoint} = @{
	Checkpoint = $Checkpoint
	Preserve = $Preserve
	Result = $Build['Result']
	Data = $null
}
$Build.Remove('Result')

$Auto = $PSCmdlet.ParameterSetName -eq 'Auto' -and $Auto
$Resume = $PSCmdlet.ParameterSetName -eq 'Resume' -and $Resume

if ($Auto) {
	$Resume = [System.IO.File]::Exists($Checkpoint)
}

if ($Resume) {
	if (![System.IO.File]::Exists($Checkpoint)) {throw "Missing checkpoint '$Checkpoint'."}
	${*checkpoint}.Data = try {Import-Clixml $Checkpoint} catch {throw 'Invalid checkpoint file?'}

	foreach($_ in @($Build.get_Keys())) {
		if ($_ -ne 'Safe' -and $_ -ne 'Summary') {
			$Build.Remove($_)
		}
	}
	$Build.Task = ${*checkpoint}.Data.Task
	$Build.File = ${*checkpoint}.Data.File
	$Build = $Build + ${*checkpoint}.Data.Prm1
}

${*checkpoint}.XBuild = {
	if (${*checkpoint}.Data) {
		foreach($_ in ${*checkpoint}.Data.Done) {
			${*}.All[$_].Elapsed = [TimeSpan]::Zero
		}
		foreach($_ in ${*checkpoint}.Data.Prm2.GetEnumerator()) {
			Set-Variable $_.Key $_.Value -Scope Script
		}
		if ($_ = ${*}.Data['Checkpoint.Import']) {
			. *Run $_ ${*checkpoint}.Data.User
		}
	}
}

${*checkpoint}.XCheck = {
	Export-Clixml ${*checkpoint}.Checkpoint -InputObject @{
		User = *Run ${*}.Data['Checkpoint.Export']
		Task = $BuildTask
		File = $BuildFile
		Prm1 = ${*}.SP
		Prm2 = $(
			$r = @{}
			foreach($_ in ${*}.DP.get_Keys()) {
				$r[$_] = Get-Variable -Name $_ -Scope Script -ValueOnly
			}
			$r
		)
		Done = @(
			foreach($t in ${*}.All.get_Values()) {
				if ($t.Elapsed -and !$t.Error) {
					$t.Name
				}
			}
		)
	}
}

$_ = $Build
Remove-Variable Checkpoint, Build, Preserve, Resume, Auto

Set-Alias Invoke-Build (Join-Path (Split-Path $MyInvocation.MyCommand.Path) Invoke-Build.ps1)
Invoke-Build @_ -Result ${*checkpoint}

if (!${*checkpoint}.Value.Error -and !${*checkpoint}.Preserve) {
	[System.IO.File]::Delete(${*checkpoint}.Checkpoint)
}
}
catch {
	if ($_.InvocationInfo.ScriptName -notmatch '\b(Invoke-Build|Build-Checkpoint)\.ps1$') {throw}
	$PSCmdlet.ThrowTerminatingError($_)
}
finally {
	if ($r = ${*checkpoint}.Result) {
		if ($r -is [string]) {
			New-Variable $r ${*checkpoint}.Value -Scope 1 -Force
		}
		else {
			$r.Value = ${*checkpoint}.Value
		}
	}
}
tools\InvokeBuild\5.12.1\Build-Parallel.ps1
<#
Copyright (c) Roman Kuzmin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
#>

#.ExternalHelp Help.xml
param(
	[Parameter(Position=0)]
	[hashtable[]]$Build
	,
	[object]$Result
	,
	[int]$Timeout=[int]::MaxValue
	,
	[int]$MaximumBuilds=[Environment]::ProcessorCount
	,
	[switch]$FailHard
	,
	[string[]]$ShowParameter
)

$ErrorActionPreference = 1

# info, result
$info = [PSCustomObject]@{
	Tasks = [System.Collections.Generic.List[object]]@()
	Errors = [System.Collections.Generic.List[object]]@()
	Warnings = [System.Collections.Generic.List[object]]@()
	Started = [DateTime]::Now
	Elapsed = $null
}
if ($Result) {
	if ($Result -is [string]) {
		New-Variable $Result $info -Scope 1 -Force
	}
	else {
		$Result.Value = $info
	}
}

# no builds
if (!$Build) {return}

# get and source the engine
$ib = Join-Path (Split-Path $MyInvocation.MyCommand.Path) Invoke-Build.ps1
try {. $ib} catch {$PSCmdlet.ThrowTerminatingError($_)}

### make works, check scripts
$works = @()
for ($1 = 0; $1 -lt $Build.Count) {
	$b = @{} + $Build[$1]
	$Build[$1++] = $b

	if ($file = $b['File']) {
		if (![System.IO.File]::Exists(($file = *Path $file))) {*Die "Missing script '$file'." 13}
	}
	elseif (!($file = Get-BuildFile (*Path))) {
		*Die "Missing default script in build $1." 5
	}

	$b.Result = @{}
	$b.File = $file
	$b.Safe = $true

	$work = @{}
	$works += $work
	$work.Build = $b
	$work.Done = $false
	$work.Error1 = $null
	$work.Error2 = $null
	$work.Title = "($1/$($Build.Count)) $file"
	if ($ShowParameter) {
		foreach($p in $ShowParameter) {
			$work.Title += " $($p)='$($b[$p])'"
		}
	}
}

### prepare logs and make shells
foreach($work in $works) {
	$b = $work.Build
	if ($log = $b['Log']) {
		$work.Temp = $false
		$b.Remove('Log')
		[System.IO.File]::Delete(($log = *Path $log))
	}
	else {
		$work.Temp = $true
		$log = [System.IO.Path]::GetTempFileName()
	}
	$work.Log = $log
	$work.PS = [PowerShell]::Create().AddCommand($ib).AddParameters($b).AddCommand('Out-File').AddParameter('FilePath', $log).AddParameter('Encoding', 'UTF8')
}

function Write-Log($work) {
	$file = $work.Log
	if ($work.Temp) {
		try {
			$read = [System.IO.File]::OpenText($file)
			while($null -ne ($_ = $read.ReadLine())) {$_}
			$read.Close()
		}
		catch {
			Write-Warning $_
		}
		[System.IO.File]::Delete($file)
	}
	else {
		"Log: $file"
	}
}

### main
if ($MaximumBuilds -lt 1) {*Die "MaximumBuilds should be a positive number." 5}
$MaximumBuilds = [math]::Min($MaximumBuilds, $Build.Count)
$stage = [System.Collections.Generic.List[object]]@()
$iWork = 0
$abort = ''
$failures = @()
$stopwatch = [Diagnostics.Stopwatch]::StartNew()
try {
	for() {
		### stage next work(s), BeginInvoke
		while($stage.Count -lt $MaximumBuilds -and $iWork -lt $works.Count) {
			$work = $works[$iWork++]
			$stage.Add($work)

			Write-Build Cyan "Start $($work.Title)"
			$work.Job = $work.PS.BeginInvoke()
		}
		if (!$stage) {break}

		### wait for any staged
		$waits = New-Object System.Collections.Generic.List[System.Threading.WaitHandle]
		foreach($work in $stage) {$waits.Add($work.Job.AsyncWaitHandle)}
		$time = $Timeout - $stopwatch.ElapsedMilliseconds
		$index = [System.Threading.WaitHandle]::WaitAny($waits.ToArray(), $time, $true)
		if ($index -eq [System.Threading.WaitHandle]::WaitTimeout) {
			$abort = 'Build timed out.'
			break
		}

		### unstage done, EndInvoke
		$work = $stage[$index]
		$stage.RemoveAt($index)
		$work.Done = $true
		try {
			$work.PS.EndInvoke($work.Job)
			$work.Error2 = $work.Build.Result.Value.Error
		}
		catch {
			$work.Error1 = "Invalid build arguments or script. Error: $_"
		}

		### abort?
		if (($work.Error1 -or $work.Error2) -and $FailHard) {
			$abort = "Aborted by $($work.Title)"
			break
		}
	}

	### finish works
	foreach($work in $works) {
		Write-Build Cyan "Build $($work.Title):"

		### get error and dispose
		$runtime = $false
		$_ = try {
			if ($work.Done) {
				if ($work.Error1) {
					$work.Error1
				}
				else {
					$runtime = $true
					$r = $work.Build.Result.Value
					$info.Tasks.AddRange($r.Tasks)
					$info.Errors.AddRange($r.Errors)
					$info.Warnings.AddRange($r.Warnings)
					$r.Error
				}
			}
			else {
				$work.PS.Stop()
				$abort
			}

			### streams
			$streams = $work.PS.Streams

			if ($work.Build['Verbose']) {
				foreach($_ in $streams.Verbose) {
					Write-Verbose $_ -Verbose
				}
			}

			if ($var = $work.Build['InformationVariable']) {
				New-Variable $var ([System.Collections.Generic.List[object]]$streams.Information) -Scope 1 -Force
			}

			if ($null -ne $work.Build['InformationAction']) {
				foreach($_ in $streams.Information) {
					Write-Information $_ -InformationAction $work.Build.InformationAction
				}
			}
		}
		catch {
			$_
		}
		finally {
			$work.PS.Dispose()
		}

		### log
		Write-Log $work

		### result
		if ($_) {
			Write-Build Cyan "Build $($work.Title) FAILED."
			$_ = if ($_ -is [System.Management.Automation.ErrorRecord] -and $runtime) {*Msg $_ $_} else {"$_"}
			Write-Build Red "ERROR: $_"
			$failures += @{
				File = $work.Title
				Error = $_
			}
		}
		else {
			Write-Build Cyan "Build $($work.Title) succeeded."
		}
	}

	### fail?
	if ($failures) {
		*Die ($(
			"Failed builds:"
			foreach($_ in $failures) {
				"Build: $($_.File)"
				"ERROR: $($_.Error)"
			}
		) -join [Environment]::NewLine)
	}
}
finally {
	$errors = $info.Errors.Count
	$warnings = $info.Warnings.Count
	$info.Elapsed = [DateTime]::Now - $info.Started

	if (($up = $PSCmdlet.SessionState.PSVariable.Get('*')) -and ($up = if ($up.Description -eq 'IB') {$up.Value})) {
		$up.Tasks.AddRange($info.Tasks)
		$up.Errors.AddRange($info.Errors)
		$up.Warnings.AddRange($info.Warnings)
	}

	$color, $text = if ($failures) {12, 'Builds FAILED'}
	elseif ($errors) {14, 'Builds completed with errors'}
	elseif ($warnings) {14, 'Builds succeeded with warnings'}
	else {10, 'Builds succeeded'}

	Write-Build $color @"
Tasks: $($info.Tasks.Count) tasks, $errors errors, $warnings warnings
$text. $($Build.Count) builds, $($failures.Count) failed $($info.Elapsed)
"@
}
tools\InvokeBuild\5.12.1\Help.xml
<?xml version="1.0" encoding="utf-8"?>
<helpItems xmlns="http://msh" schema="maml">
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Invoke-Build.ps1</command:name>
<maml:description>
<maml:para>Invoke-Build - Build Automation in PowerShell</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>The command invokes so called tasks defined in a PowerShell script.
Let&apos;s call this process build and a script with tasks build script.

A build script defines parameters, variables, and one or more tasks.
Any code is invoked with the current location set to $BuildRoot,
the script directory. $ErrorActionPreference is set to &apos;Stop&apos;.

SCRIPT PARAMETERS

Build scripts define parameters as usual using the param() block.
On calling, specify them for Invoke-Build as if they are its own.

Known issue #4. Specify script switches after Task and File.

The following parameter names are reserved for the engine:
Task, File, Result, Safe, Summary, WhatIf

COMMANDS AND HELP

The following commands are available for build scripts:

    task      (Add-BuildTask)
    exec      (Invoke-BuildExec)
    assert    (Assert-Build)
    equals    (Assert-BuildEquals)
    remove    (Remove-BuildItem)
    property  (Get-BuildProperty)
    requires  (Test-BuildAsset)
    use       (Use-BuildAlias)

    Confirm-Build
    Get-BuildError
    Get-BuildSynopsis
    Resolve-MSBuild
    Set-BuildFooter
    Set-BuildHeader
    Use-BuildEnv
    Write-Build
    Write-Warning [1]

[1] Write-Warning is redefined internally in order to count warnings in
a build script and nested scripts. Warnings in modules are not counted.

To get commands help, dot-source Invoke-Build and then call help:

    PS&gt; . Invoke-Build
    PS&gt; help task -full

SPECIAL ALIASES

    Invoke-Build
    Build-Parallel

These aliases are for the scripts Invoke-Build.ps1 and Build-Parallel.ps1.
Use them for calling nested builds, i.e. omit script extensions and paths.

PUBLIC VARIABLES

    $OriginalLocation - where the build is invoked
    $WhatIf - WhatIf mode, Invoke-Build parameter
    $BuildRoot - build script location, by default
    $BuildFile - build script path
    $BuildTask - initial tasks
    $Task - current task
    $Job - current job

$BuildRoot may be changed by scripts on loading in order to set a custom
build root directory. Other variables should not be changed.

$Task is available for script blocks defined by task parameters If, Inputs,
Outputs, and Jobs and by blocks Enter|Exit-BuildTask, Enter|Exit-BuildJob,
Set-BuildHeader, Set-BuildFooter.

    $Task properties:

    - Name - [string], task name
    - Jobs - [object[]], task jobs
    - Started - [DateTime], task start time

    And in Exit-BuildTask:

    - Error - task error or null
    - Elapsed - [TimeSpan], task duration

$Task is also defined in the script scope. It has the only property Name
which is set to $BuildFile, the build script path.

BUILD BLOCKS

Scripts may define special script blocks. They are invoked:

    Enter-Build {} - before the first task
    Exit-Build {} - after the last task

    Enter-BuildTask {} - before each task
    Exit-BuildTask {} - after each task

    Enter-BuildJob {} - before each task action
    Exit-BuildJob {} - after each task action

    Set-BuildHeader {param($Path)} - to write task headers
    Set-BuildFooter {param($Path)} - to write task footers

Blocks are not called on WhatIf.
Nested builds do not inherit parent blocks.
If Enter-X is called then Exit-X is also called, even on failures.

Enter-Build and Exit-Build are invoked in the script scope. Enter-Build is
suitable for initialization and it can output text unlike the build script.

Enter-BuildTask, Exit-BuildTask, Enter-BuildJob, and Exit-BuildJob are
invoked in the same scope, the parent of task action blocks.

PRIVATE STUFF

Function and variable names starting with &apos;*&apos; are reserved for the engine.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-Build.ps1</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Task</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>File</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Safe</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Summary</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>WhatIf</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Task</maml:name>
<maml:description>
<maml:para>One or more tasks to be invoked. If it is not specified, null, empty,
or equal to &apos;.&apos; then the task &apos;.&apos; is invoked if it exists, otherwise
the first added task is invoked.

Names with wildcard characters are reserved for special cases.

SAFE REFERENCES

If a task &apos;X&apos; is referenced as &apos;?X&apos; then it is allowed to fail without
breaking the build, i.e. other tasks specified after X will be invoked.

SPECIAL TASKS

? - Tells to list tasks with brief information and check for errors.
Task synopses are defined in preceding comments as

    # Synopsis: ...

or

    &lt;#
    .Synopsis
    ...
    #&gt;

?? - Tells to collect and get all tasks as an ordered dictionary.
It can be used by external tools for analysis, completion, etc.

Tasks ? and ?? set $WhatIf to true. Properly designed build scripts
should not perform anything significant if $WhatIf is set to true.

* - Tells to invoke all tasks, for example when tasks are tests.

** - Invokes * for all files *.test.ps1 found recursively in the
current directory or a directory specified by the parameter File.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>File</maml:name>
<maml:description>
<maml:para>The script which adds tasks using the command &apos;task&apos; (Add-BuildTask).

If File is omitted then Invoke-Build looks for *.build.ps1 files in the
current location and takes the first in Sort-Object order.

If the file is not found then a command set by the environment variable
InvokeBuildGetFile is invoked with the directory path as an argument.
This command may return the full path of a special build script.

If the file is still not found then parent directories are searched.

DIRECTORY PATH

File accepts directory paths as well. The build script is resolved as
described above for the specified directory without searching parents.

INLINE SCRIPT

File also accepts script blocks. In this case $BuildFile is the calling
script, if any, or null. The default $BuildRoot is $BuildFile directory
or the current location.

Script parameters, parallel, and persistent builds are not supported.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<maml:description>
<maml:para>Tells to make the build result. Normally it is the name of a variable
created in the calling scope. Or it is a hashtable which entry Value
contains the result.

Result properties:

    All - all available tasks
    Error - a terminating build error
    Tasks - invoked tasks including nested
    Errors - error objects including nested
    Warnings - warning objects including nested
    Redefined - list of original redefined tasks

Tasks is a list of objects:

    Name - task name
    Jobs - task jobs
    Error - task error
    Started - start time
    Elapsed - task duration
    InvocationInfo - task location (.ScriptName, .ScriptLineNumber)

Errors is a list of objects:

    Error - original error
    File - current $BuildFile
    Task - current $Task or null for other errors

Warnings is a list of objects:

    Message - warning message
    File - current $BuildFile
    Task - current $Task or null for other warnings

Do not change these data and do not use not documented members.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Safe</maml:name>
<maml:description>
<maml:para>Tells to catch a build failure, store an error as the property Error of
Result and return quietly. A caller should use Result and check Error.

Some exceptions are possible even in the safe mode. They show serious
errors, not build failures. For example, a build script is missing.

When Safe is used together with the special task ** (invoke *.test.ps1)
then task failures stop current test scripts, not the whole testing.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Summary</maml:name>
<maml:description>
<maml:para>Tells to show summary information after the build. It includes task
durations, names, locations, and error messages.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>WhatIf</maml:name>
<maml:description>
<maml:para>Tells to show tasks and jobs to be invoked and some analysis of used
parameters and environment variables. See Show-TaskHelp for details.

If a script does anything but adding tasks then it should check for
$WhatIf and skip the real actions in order to support WhatIf calls.
Alternatively, use the Enter-Build block for pre-build actions.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Text</maml:name>
</dev:type>
<maml:description>
<maml:para>Build log which includes task records and engine messages, warnings,
errors, and output from build script tasks and special blocks.

The script itself should not output anything. Unexpected script output
causes warnings, in the future it may be treated as an error.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>## How to call Invoke-Build in order to deal with build failures.
## Use one of the below techniques or you may miss some failures.

## (1/2) If you do not want to catch errors and just want the calling
## script to stop on build failures then

$ErrorActionPreference = &apos;Stop&apos;
Invoke-Build ...

## (2/2) If you want to catch build errors and proceed further depending
## on them then use try/catch, $ErrorActionPreference does not matter:

try {
    Invoke-Build ...
    # Build completed
}
catch {
    # Build FAILED, $_ is the error
}</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Invoke tasks Build and Test from the default script with parameters.
# The script defines parameters Output and WarningLevel by param().

Invoke-Build Build, Test -Output log.txt -WarningLevel 4</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title>
<dev:code># Show tasks in the default script and the specified script

Invoke-Build ?
Invoke-Build ? Project.build.ps1

# Custom formatting is possible, too

Invoke-Build ? | Format-Table -AutoSize
Invoke-Build ? | Format-List Name, Synopsis</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 4 --------------------------</maml:title>
<dev:code># Get task names without invoking for listing, TabExpansion, etc.

$all = Invoke-Build ??
$all.Keys</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 5 --------------------------</maml:title>
<dev:code># Invoke all in Test1.test.ps1 and all in Tests\...\*.test.ps1

Invoke-Build * Test1.test.ps1
Invoke-Build ** Tests</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 6 --------------------------</maml:title>
<dev:code># How to use build results, e.g. for summary

try {
    # Invoke build and get the variable Result
    Invoke-Build -Result Result
}
finally {
    # Show build error
    &quot;Build error: $(if ($Result.Error) {$Result.Error} else {&apos;None&apos;})&quot;

    # Show task summary
    $Result.Tasks | Format-Table Elapsed, Name, Error -AutoSize
}</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Wiki</maml:linkText>
<maml:uri>https://github.com/nightroman/Invoke-Build/wiki</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Project</maml:linkText>
<maml:uri>https://github.com/nightroman/Invoke-Build</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Build-Checkpoint</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Build-Parallel</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>For other commands, at first invoke:</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>PS&gt; . Invoke-Build</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>task      (Add-BuildTask)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>exec      (Invoke-BuildExec)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>assert    (Assert-Build)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>equals    (Assert-BuildEquals)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>remove    (Remove-BuildItem)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>property  (Get-BuildProperty)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>requires  (Test-BuildAsset)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>use       (Use-BuildAlias)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Confirm-Build</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-BuildError</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-BuildSynopsis</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Resolve-MSBuild</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-BuildFooter</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-BuildHeader</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Write-Build</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Add-BuildTask</command:name>
<maml:description>
<maml:para>(task) Defines and adds a task.</maml:para>
</maml:description>
<command:verb>Add</command:verb>
<command:noun>BuildTask</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;task&apos;. It is normally used in the build script scope
but it can be called from another script or function. Build scripts should
have at least one task.

This command is all that build scripts really need. Tasks are main build
blocks. Other build commands are helpers, scripts do not have to use them.

In addition to task parameters, you may use task help comments, synopses,
preceding task definitions:

    # Synopsis: ...
    task ...

Synopses are used in task help information returned by the command

    Invoke-Build ?

To get a task synopsis during a build, use Get-BuildSynopsis.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Add-BuildTask</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Jobs</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>After</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Before</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Data</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Done</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>If</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Inputs</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Outputs</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Source</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Partial</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>The task name. Wildcard characters are deprecated and &quot;?&quot; must not be
the first character. Duplicated names are allowed, each added task
overrides previously added with the same name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Jobs</maml:name>
<maml:description>
<maml:para>Specifies one or more task jobs or a hashtable with actual parameters.
Jobs are other task references and own actions, script blocks. Any
number of jobs is allowed. Jobs are invoked in the specified order.

Valid jobs are:

    [string] - an existing task name, normal reference
    [string] &quot;?Name&quot; - safe reference to a task allowed to fail
    [scriptblock] - action, a script block invoked for this task

Special value:

    [hashtable] which contains the actual task parameters in addition
    to the task name. This task definition is more convenient with
    complex parameters, often typical for incremental tasks.

    Example:
        task Name @{
            Inputs = {...}
            Outputs = {...}
            Partial = $true
            Jobs = {
                process {...}
            }
        }</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>After</maml:name>
<maml:description>
<maml:para>Tells to add this task to the end of jobs of the specified tasks.

Altered tasks are defined as normal references (TaskName) or safe
references (?TaskName). In the latter case this inserted task may
fail without stopping a build.

Parameters After and Before are used in order to alter task jobs
in special cases when direct changes in task source code are not
suitable. Use Jobs in order to define relations in usual cases.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Before</maml:name>
<maml:description>
<maml:para>Tells to insert this task to jobs of the specified tasks.
It is inserted before the first action or added to the end.

See After for details.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Data</maml:name>
<maml:description>
<maml:para>Any object attached to the task. It is not used by the engine.
When the task is invoked this object is available as $Task.Data.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Done</maml:name>
<maml:description>
<maml:para>Specifies the command or a script block which is invoked after the
task. Custom handlers should check for $Task.Error if it matters.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>If</maml:name>
<maml:description>
<maml:para>Specifies the optional condition to be evaluated. If the condition
evaluates to false then the task is not invoked. The condition is
defined in one of two ways depending on the requirements.

Using standard Boolean notation (parenthesis) the condition is checked
once when the task is defined. A use case for this notation might be
evaluating a script parameter or another sort of global condition.

    Example:
        task Task1 -If ($Param1 -eq ...) {...}
        task Task2 -If ($PSVersionTable.PSVersion.Major -ge 5) {...}

Using script block notation (curly braces) the condition is evaluated
on task invocation. If a task is referenced by several tasks then the
condition is evaluated each time until it gets true and the task is
invoked. The script block notation is normally used for a condition
that may be defined or changed during the build or just expensive.

    Example:
        task SomeTask -If {...} {...}</maml:para>
</maml:description>
<dev:defaultValue>$true</dev:defaultValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Inputs</maml:name>
<maml:description>
<maml:para>Specifies the input items, tells to process the task as incremental,
and requires the parameter Outputs with the optional switch Partial.

Inputs are file items or paths or a script block which gets them.

Outputs are file paths or a script block which gets them.
A script block is invoked with input paths piped to it.

Automatic variables for incremental task actions:

    $Inputs - full input paths, array of strings
    $Outputs - result of the evaluated Outputs

With the switch Partial the task is processed as partial incremental.
There must be one-to-one correspondence between Inputs and Outputs.

Partial task actions often contain &quot;process {}&quot; blocks.
Two more automatic variables are available for them:

    $_ - full path of an input item
    $2 - corresponding output path

See also wiki topics about incremental tasks:
https://github.com/nightroman/Invoke-Build/wiki</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Outputs</maml:name>
<maml:description>
<maml:para>Specifies the output paths of the incremental task, either directly on
task creation or as a script block invoked with the task. It is used
together with Inputs. See Inputs for details.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Partial</maml:name>
<maml:description>
<maml:para>Tells to process the incremental task as partial incremental.
It is used with Inputs and Outputs. See Inputs for details.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Source</maml:name>
<maml:description>
<maml:para>Specifies the task source. It is used by wrapper functions in order to
provide the actual source for location messages and synopsis comments.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Dummy task with no jobs
task Task1

# Alias of another task
task Task2 Task1

# Combination of tasks
task Task3 Task1, Task2

# Simple action task
task Task4 {
    # action
}

# Typical complex task: referenced task(s) and one own action
task Task5 Task1, Task2, {
    # action after referenced tasks
}

# Possible complex task: actions and tasks in any required order
task Task6 {
    # action before Task1
},
Task1, {
    # action after Task1 and before Task2
},
Task2</dev:code>
<dev:remarks>
<maml:para>This example shows various possible combinations of task jobs.</maml:para>
<maml:para></maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Synopsis: Complex task with parameters as a hashtable.
task TestAndAnalyse @{
    If = !$SkipAnalyse
    Inputs = {
        Get-ChildItem . -Recurse -Include *.ps1, *.psm1
    }
    Outputs = {
        &apos;Analyser.log&apos;
    }
    Jobs = &apos;Test&apos;, {
        Invoke-ScriptAnalyzer . &gt; Analyser.log
    }
}

# Synopsis: Simple task with usual parameters.
task Test -If (!$SkipTest) {
    Invoke-Pester
}</dev:code>
<dev:remarks>
<maml:para>Tasks with complex parameters are often difficult to compose in a readable
way. In such cases use a hashtable in order to specify task parameters in
addition to the task name. Keys and values correspond to parameter names
and values.</maml:para>
</dev:remarks>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Get-BuildError</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-BuildSynopsis</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:uri>https://github.com/nightroman/Invoke-Build/wiki</maml:uri>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Get-BuildError</command:name>
<maml:description>
<maml:para>Gets the specified task error.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildError</command:noun>
</command:details>
<maml:description>
<maml:para>The specified task is usually safe referenced in the build (?name) and a
caller (usually a downstream task) gets its potential error for analysis.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildError</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Task</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Task</maml:name>
<maml:description>
<maml:para>Name of the task which error is requested.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Error</maml:name>
</dev:type>
<maml:description>
<maml:para>An error or null if the task has not failed.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Add-BuildTask</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Assert-Build</command:name>
<maml:description>
<maml:para>(assert) Checks for a condition.</maml:para>
</maml:description>
<command:verb>Assert</command:verb>
<command:noun>Build</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;assert&apos;. This command checks for a condition and
if it is not true throws an error with the default or specified message.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Assert-Build</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Condition</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Message</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Condition</maml:name>
<maml:description>
<maml:para>The condition.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Message</maml:name>
<maml:description>
<maml:para>An optional message describing the assertion condition.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Assert-BuildEquals</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Assert-BuildEquals</command:name>
<maml:description>
<maml:para>(equals) Verifies that two specified objects are equal.</maml:para>
</maml:description>
<command:verb>Assert</command:verb>
<command:noun>BuildEquals</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;equals&apos;. This command verifies that two specified
objects are equal using [Object]::Equals(). If objects are not equal the
command fails with a message showing object values and types.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Assert-BuildEquals</maml:name>
<command:parameter required="false" position="0" >
<maml:name>A</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>B</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>A</maml:name>
<maml:description>
<maml:para>The first object.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>B</maml:name>
<maml:description>
<maml:para>The second object.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Assert-Build</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Get-BuildProperty</command:name>
<maml:description>
<maml:para>(property) Gets the session or environment variable or the default.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildProperty</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;property&apos;. The command returns:

    - session variable value if it is not $null or &apos;&apos;
    - environment variable if it is not $null or &apos;&apos;
    - default value if it is not $null
    - error</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildProperty</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Value</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the session or environment variable name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Value</maml:name>
<maml:description>
<maml:para>Specifies the default value. If it is omitted or null then the variable
must exist with a not empty value. Otherwise an error is thrown.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Object</maml:name>
</dev:type>
<maml:description>
<maml:para>Requested property value.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Inherit an existing value or throw an error

$OutputPath = property OutputPath</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Get an existing value or use the default

$WarningLevel = property WarningLevel 4</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Test-BuildAsset</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Get-BuildSynopsis</command:name>
<maml:description>
<maml:para>Gets the task synopsis.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildSynopsis</command:noun>
</command:details>
<maml:description>
<maml:para>Gets the specified task synopsis if it is available.

Task synopses are defined in preceding comments as

    # Synopsis: ...

or

    &lt;#
    .Synopsis
    ...
    #&gt;

This function may be used in Set-BuildHeader for printing task synopses.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildSynopsis</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Task</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Hash</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Task</maml:name>
<maml:description>
<maml:para>The task object. During the build, the current task is available as the
automatic variable $Task.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Hash</maml:name>
<maml:description>
<maml:para>A hashtable for caching. Build scripts do not have to specify it, the
internal cache is used by default. It is designed for external tools.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>String</maml:name>
</dev:type>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Headers: print task paths as usual and synopses in addition
Set-BuildHeader {
    param($Path)
    Write-Build Cyan &quot;Task $Path : $(Get-BuildSynopsis $Task)&quot;
}

# Synopsis: This task prints its own synopsis.
task Task1 {
    &apos;My synopsis : &apos; + (Get-BuildSynopsis $Task)
}</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Set-BuildFooter</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-BuildHeader</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Invoke-BuildExec</command:name>
<maml:description>
<maml:para>(exec) Invokes an application and checks $LastExitCode.</maml:para>
</maml:description>
<command:verb>Invoke</command:verb>
<command:noun>BuildExec</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;exec&apos;. It invokes the specified script block which
is supposed to call an executable. Then $LastExitCode is checked. If it
does not fit to the specified values (0 by default) an error is thrown.

If you have any issues with standard error output of the invoked app, try
using `exec` with -ErrorAction Continue, SilentlyContinue, or Ignore. This
does not affect failures of `exec`, they still depend on the app exit code.
But this may work around some known PowerShell issues with standard errors.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-BuildExec</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Command</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>ExitCode</maml:name>
<command:parameterValue required="true">Int32[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>ErrorMessage</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Echo</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>StdErr</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Command</maml:name>
<maml:description>
<maml:para>Command that invokes an executable which exit code is checked. It must
invoke an application directly (.exe) or not (.cmd, .bat), otherwise
$LastExitCode is not set and may contain the code of another command.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>ExitCode</maml:name>
<maml:description>
<maml:para>Valid exit codes (e.g. 0..3 for robocopy).</maml:para>
</maml:description>
<dev:defaultValue>@(0)</dev:defaultValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>ErrorMessage</maml:name>
<maml:description>
<maml:para>Specifies the text included to standard error messages.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Echo</maml:name>
<maml:description>
<maml:para>Tells to write the command and its used variable values.
WARNING: With echo you may expose sensitive information.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>StdErr</maml:name>
<maml:description>
<maml:para>Tells to set $ErrorActionPreference to Continue, capture all output and
write as strings. Then, if the exit code is failure, add the standard
error output text to the error message.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Objects</maml:name>
</dev:type>
<maml:description>
<maml:para>Output of the specified command.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Call robocopy (0..3 are valid exit codes)

exec { robocopy Source Target /mir } (0..3)</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Use-BuildAlias</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Use-BuildEnv</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Remove-BuildItem</command:name>
<maml:description>
<maml:para>(remove) Removes specified items.</maml:para>
</maml:description>
<command:verb>Remove</command:verb>
<command:noun>BuildItem</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;remove&apos;. This command removes existing items,
ignores missing items, and fails if it cannot remove existing items.

Use the switch Verbose in order to output messages about removing
existing and skipping missing items or patterns specified by Path.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-BuildItem</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Path</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" globbing="true" >
<maml:name>Path</maml:name>
<maml:description>
<maml:para>Specifies the items to be removed. Wildcards are allowed.
The parameter is mostly the same as Path of Remove-Item.
For sanity, paths with only ., *, \, / are not allowed.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Remove some temporary items

remove bin, obj, *.test.log</dev:code>
</command:example>
</command:examples>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Set-BuildFooter</command:name>
<maml:description>
<maml:para>Tells how to write task footers.</maml:para>
</maml:description>
<command:verb>Set</command:verb>
<command:noun>BuildFooter</command:noun>
</command:details>
<maml:description>
<maml:para>This build block is used in order to change the default task footer format.
Use the automatic variable $Task in order to get the current task data.
Use Write-Build in order to write with colors.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Set-BuildFooter</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Script</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Script</maml:name>
<maml:description>
<maml:para>The script like {param($Path) ...} which is used in order to write task
footers. The parameter Path includes the parent and current task names.

In order to omit task footers, set an empty block:

    Set-BuildFooter {}</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Use the usual footer format but change the color
Set-BuildFooter {
    param($Path)
    Write-Build DarkGray &quot;Done $Path $($Task.Elapsed)&quot;
}

# Synopsis: Data for footers in addition to $Path and $Task.Elapsed
task Task1 {
    &apos;Task name     : &apos; + $Task.Name
    &apos;Start time    : &apos; + $Task.Started
    &apos;Location path : &apos; + $Task.InvocationInfo.ScriptName
    &apos;Location line : &apos; + $Task.InvocationInfo.ScriptLineNumber
}</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Get-BuildSynopsis</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-BuildHeader</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Write-Build</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Set-BuildHeader</command:name>
<maml:description>
<maml:para>Tells how to write task headers.</maml:para>
</maml:description>
<command:verb>Set</command:verb>
<command:noun>BuildHeader</command:noun>
</command:details>
<maml:description>
<maml:para>This build block is used in order to change the default task header format.
Use the automatic variable $Task in order to get the current task data.
Use Write-Build in order to write with colors.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Set-BuildHeader</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Script</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Script</maml:name>
<maml:description>
<maml:para>The script like {param($Path) ...} which is used in order to write task
headers. The parameter Path includes the parent and current task names.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Headers: write task paths as usual and synopses in addition
Set-BuildHeader {
    param($Path)
    Write-Build Cyan &quot;Task $Path --- $(Get-BuildSynopsis $Task)&quot;
}

# Synopsis: Data for headers in addition to $Path and Get-BuildSynopsis
task Task1 {
    &apos;Task name     : &apos; + $Task.Name
    &apos;Start time    : &apos; + $Task.Started
    &apos;Location path : &apos; + $Task.InvocationInfo.ScriptName
    &apos;Location line : &apos; + $Task.InvocationInfo.ScriptLineNumber
}</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Get-BuildSynopsis</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-BuildFooter</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Write-Build</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Test-BuildAsset</command:name>
<maml:description>
<maml:para>(requires) Checks for required build assets.</maml:para>
</maml:description>
<command:verb>Test</command:verb>
<command:noun>BuildAsset</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;requires&apos;. This command tests the specified assets.
It fails if any is missing. It is used in script code (common assets) and
in tasks (individual assets).</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Test-BuildAsset</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Variable</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Environment</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Path</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Variable</maml:name>
<maml:description>
<maml:para>Specifies the required session variable names and tells to fail if a
variable is missing or its value is null or empty string.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Environment</maml:name>
<maml:description>
<maml:para>Specifies the required environment variable names.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Path</maml:name>
<maml:description>
<maml:para>Specifies literal paths to be tested by Test-Path. If the specified
expression uses required assets then test these assets first by a
separate command.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<maml:description>
<maml:para>Specifies session or environment variable names and tells to fail if a
variable is missing or its value is null or empty string.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Get-BuildProperty</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Use-BuildAlias</command:name>
<maml:description>
<maml:para>(use) Sets framework or directory tool aliases.</maml:para>
</maml:description>
<command:verb>Use</command:verb>
<command:noun>BuildAlias</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;use&apos;. Invoke-Build does not change the system path
in order to make framework tools available by names. This is not suitable
for using mixed framework tools (in different tasks, scripts, parallel
builds). Instead, this function is used for setting tool aliases in the
scope where it is called.

This command may be used in the script scope to make aliases for all tasks.
But it can be called from tasks in order to use more task specific tools.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Use-BuildAlias</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Path</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Path</maml:name>
<maml:description>
<maml:para>Specifies the tools directory.

If it is * or it starts with digits followed by a dot then the MSBuild
path is resolved using the package script Resolve-MSBuild.ps1. Build
scripts may invoke it directly by the provided alias Resolve-MSBuild.
The optional suffix x86 tells to use 32-bit MSBuild.

    For just MSBuild use Resolve-MSBuild instead:

        Set-Alias MSBuild (Resolve-MSBuild ...)
        MSBuild ...

    or

        $MSBuild = Resolve-MSBuild ...
        &amp; $MSBuild ...

If it is like Framework* then it is assumed to be a path relative to
Microsoft.NET in the Windows directory.

Otherwise it is a full or relative literal path of any directory.

Examples: *, 4.0, Framework\v4.0.30319, .\Tools</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the tool names. They become aliases in the current scope.
If it is a build script then the aliases are created for all tasks.
If it is a task then the aliases are available just for this task.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Use .NET 4.0 tools MSBuild, csc, ngen. Then call MSBuild.

use 4.0 MSBuild, csc, ngen
exec { MSBuild Some.csproj /t:Build /p:Configuration=Release }</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Invoke-BuildExec</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Resolve-MSBuild</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Confirm-Build</command:name>
<maml:description>
<maml:para>Prompts to confirm an operation.</maml:para>
</maml:description>
<command:verb>Confirm</command:verb>
<command:noun>Build</command:noun>
</command:details>
<maml:description>
<maml:para>This function prints the prompt and options: [Y] Yes [N] No [S] Suspend.
Choose Y to continue or N to skip. [S] enters the nested prompt, you may
invoke some commands end then `exit`.

Confirm-Build must not be called during non interactive builds. Scripts
should take care of this. For example, add the switch $Quiet and define
Confirm-Build as &quot;Yes to All&quot;:

    if ($Quiet) {function Confirm-Build {$true}}</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Confirm-Build</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Query</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Caption</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Query</maml:name>
<maml:description>
<maml:para>The confirmation query. If it is omitted or empty, &quot;Continue with this operation?&quot; is used.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Caption</maml:name>
<maml:description>
<maml:para>The confirmation caption. If it is omitted, the current task or script name is used.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Boolean</maml:name>
</dev:type>
</command:returnValue>
</command:returnValues>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Write-Build</command:name>
<maml:description>
<maml:para>Writes text using colors if they are supported.</maml:para>
</maml:description>
<command:verb>Write</command:verb>
<command:noun>Build</command:noun>
</command:details>
<maml:description>
<maml:para>This function is used in order to output colored text in a console or other
hosts with colors. Unlike Write-Host it is suitable for redirected output.

Write-Build is designed for tasks and build blocks, not script functions.

With PowerShell 7.2+ and $PSStyle.OutputRendering ANSI, Write-Build uses
ANSI escape sequences.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Write-Build</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Color</maml:name>
<command:parameterValue required="true">ConsoleColor</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="1" >
<maml:name>Text</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Color</maml:name>
<maml:description>
<maml:para>[System.ConsoleColor] value or its string representation.</maml:para>
<maml:para>Values : Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="1" >
<maml:name>Text</maml:name>
<maml:description>
<maml:para>Text written using colors if they are supported.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>String</maml:name>
</dev:type>
</command:returnValue>
</command:returnValues>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Use-BuildEnv</command:name>
<maml:description>
<maml:para>Invokes script with temporary changed environment variables.</maml:para>
</maml:description>
<command:verb>Use</command:verb>
<command:noun>BuildEnv</command:noun>
</command:details>
<maml:description>
<maml:para>This command sets the specified environment variables and invokes the
script. Then it restores the original values of specified variables.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Use-BuildEnv</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Env</maml:name>
<command:parameterValue required="true">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="1" >
<maml:name>Script</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Env</maml:name>
<maml:description>
<maml:para>The hashtable of environment variables used by the script.
Keys and values correspond to variable names and values.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="1" >
<maml:name>Script</maml:name>
<maml:description>
<maml:para>The script invoked with the specified variables.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Objects</maml:name>
</dev:type>
<maml:description>
<maml:para>Output of the specified script.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Invoke with temporary changed Port and Path
Use-BuildEnv @{
    Port = &apos;9780&apos;
    Path = &quot;$PSScriptRoot\Scripts;$env:Path&quot;
} {
    exec { dotnet test }
}</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Invoke-BuildExec</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Build-Parallel.ps1</command:name>
<maml:description>
<maml:para>Invokes parallel builds by Invoke-Build</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>This script invokes several build scripts simultaneously by Invoke-Build.
Number of parallel builds is set to the number of processors by default.

NOTE: Avoid using Build-Parallel in scenarios with PowerShell classes.
Known issues: https://github.com/nightroman/Invoke-Build/issues/180

VERBOSE STREAM

Verbose messages are propagated to the caller if Verbose is set to true in
build parameters. They are written all together before the build output.

    Build-Parallel @(
        @{File=...; Task=...; Verbose=$true}
        ...
    )

INFORMATION STREAM

Information messages are propagated to the caller if InformationAction is
set to Continue in build parameters. They are written all together before
the build output.

    Build-Parallel @(
        @{File=...; Task=...; InformationAction=&apos;Continue&apos;}
        ...
    )

In addition or instead, information messages are collected in the variable
specified by InformationVariable in build parameters.

    Build-Parallel @(
        @{File=...; Task=...; InformationVariable=&apos;info&apos;}
        ...
    )

    # information messages
    $info</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Build-Parallel.ps1</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Build</maml:name>
<command:parameterValue required="true">Hashtable[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>MaximumBuilds</maml:name>
<command:parameterValue required="true">Int32</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>ShowParameter</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Timeout</maml:name>
<command:parameterValue required="true">Int32</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>FailHard</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Build</maml:name>
<maml:description>
<maml:para>Build parameters defined as hashtables with these keys/data:

    Task, File, ... - Invoke-Build.ps1 and script parameters
    Log - Tells to write build output to the specified file

Any number of builds is allowed, including 0 and 1. The maximum number
of parallel builds is the number of processors by default. It can be
changed by the parameter MaximumBuilds.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>FailHard</maml:name>
<maml:description>
<maml:para>Tells to abort all builds if any build fails.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>MaximumBuilds</maml:name>
<maml:description>
<maml:para>Maximum number of builds invoked at the same time.</maml:para>
</maml:description>
<dev:defaultValue>Number of processors.</dev:defaultValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<maml:description>
<maml:para>Tells to output build results using a variable. It is either a name of
variable to be created for results or any object with the property
Value to be assigned ([ref], [hashtable]).

Result properties:

    Tasks - tasks (*)
    Errors - errors (*)
    Warnings - warnings (*)
    Started - start time
    Elapsed - build duration

(*) see: help Invoke-Build -Parameter Result</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>ShowParameter</maml:name>
<maml:description>
<maml:para>Tells to show the specified parameter values in build titles.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Timeout</maml:name>
<maml:description>
<maml:para>Maximum overall build time in milliseconds.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Text</maml:name>
</dev:type>
<maml:description>
<maml:para>Output of invoked builds and other log messages.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>Build-Parallel @(
    @{File=&apos;Project1.build.ps1&apos;}
    @{File=&apos;Project2.build.ps1&apos;; Task=&apos;MakeHelp&apos;}
    @{File=&apos;Project2.build.ps1&apos;; Task=&apos;Build&apos;, &apos;Test&apos;}
    @{File=&apos;Project3.build.ps1&apos;; Log=&apos;C:\TEMP\Project3.log&apos;}
    @{File=&apos;Project4.build.ps1&apos;; Configuration=&apos;Release&apos;}
)</dev:code>
<dev:remarks>
<maml:para>Five parallel builds are invoked with various combinations of parameters.
Note that it is fine to invoke the same build script more than once if
build flows specified by different tasks do not conflict.</maml:para>
</dev:remarks>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Invoke-Build</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Build-Checkpoint.ps1</command:name>
<maml:description>
<maml:para>Invokes persistent builds with checkpoints.</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>This command invokes the build and saves build state checkpoints after each
completed task. If the build is interrupted then it may be resumed later
with the saved checkpoint file.

The built-in Export-Clixml and Import-Clixml are used for saving checkpoints.
Keep in mind that not all data types are suitable for this serialization.

CUSTOM EXPORT AND IMPORT

By default, the command saves and restores build tasks, script path, and
all parameters declared by the build script. Tip: consider declaring some
script variables as artificial parameters in order to make them persistent.

If this is not enough for saving and restoring the build state then use
custom export and import blocks. The export block is called on writing
checkpoints, i.e. on each task. The import block is called on resuming
once, before the task to be resumed.

The export block is set by `Set-BuildData Checkpoint.Export`, e.g.

    Set-BuildData Checkpoint.Export {
        $script:var1
        $script:var2
    }

The import block is set by `Set-BuildData Checkpoint.Import`, e.g.

    Set-BuildData Checkpoint.Import {
        param($data)
        $var1, $var2 = $data
    }

The import block is called in the script scope. Thus, $var1 and $var2 are
script variables right away. We may but do not have to use the prefix.

The parameter $data is the output of Checkpoint.Export exported to clixml
and then imported from clixml.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Build-Checkpoint.ps1</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Checkpoint</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Build</maml:name>
<command:parameterValue required="true">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Preserve</maml:name>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Build-Checkpoint.ps1</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Checkpoint</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Build</maml:name>
<command:parameterValue required="true">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Auto</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Preserve</maml:name>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Build-Checkpoint.ps1</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Checkpoint</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Build</maml:name>
<command:parameterValue required="true">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Resume</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Preserve</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Checkpoint</maml:name>
<maml:description>
<maml:para>Specifies the checkpoint file (clixml). The checkpoint file is removed
after successful builds unless the switch Preserve is specified.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Build</maml:name>
<maml:description>
<maml:para>Specifies the build and script parameters. WhatIf is not supported.

When the build resumes by Resume or Auto then fields Task, File, and
script parameters are ignored and restored from the checkpoint file.
But fields Result, Safe, Summary are used as usual build parameters.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Auto</maml:name>
<maml:description>
<maml:para>Tells to start a new build if the checkpoint file is not found or
resume the build from the found checkpoint file.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Preserve</maml:name>
<maml:description>
<maml:para>Tells to preserve the checkpoint file on successful builds.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Resume</maml:name>
<maml:description>
<maml:para>Tells to resume the build from the existing checkpoint file.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Text</maml:name>
</dev:type>
<maml:description>
<maml:para>Output of the invoked build.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Invoke a persistent sequence of steps defined as tasks.
Build-Checkpoint temp.clixml @{Task = &apos;*&apos;; File = &apos;Steps.build.ps1&apos;}

# Given the above failed, resume at the failed step.
Build-Checkpoint temp.clixml -Resume</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Invoke-Build</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
</helpItems>
tools\InvokeBuild\5.12.1\Invoke-Build.ps1
<# Invoke-Build 5.12.1
Copyright (c) Roman Kuzmin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
#>

#.ExternalHelp Help.xml
param(
	[Parameter(Position=0)][string[]]$Task,
	[Parameter(Position=1)]$File,
	$Result,
	[switch]$Safe,
	[switch]$Summary,
	[switch]$WhatIf
)

dynamicparam {

function *Path($P) {
	$PSCmdlet.GetUnresolvedProviderPathFromPSPath($P)
}

function *Die($M, $C=0) {
	$PSCmdlet.ThrowTerminatingError((New-Object System.Management.Automation.ErrorRecord ([Exception]"$M"), $null, $C, $null))
}

function Get-BuildFile($Path, [switch]$Here) {
	do {
		if (($f = [System.IO.Directory]::GetFiles($Path, '*.build.ps1')).Length -eq 1) {return $f}
		if ($f) {return $($f | Sort-Object)[0]}
		if (($c = $env:InvokeBuildGetFile) -and ($f = & $c $Path)) {return $f}
	} while(!$Here -and ($Path = Split-Path $Path))
}

if ($MyInvocation.InvocationName -eq '.') {return}
trap {*Die $_ 5}

$p = if ($_ = $PSCmdlet.SessionState.PSVariable.Get('*')) {if ($_.Description -eq 'IB') {$_.Value}}
$c, $r, $a = $null
New-Variable * -Description IB ([PSCustomObject]@{
	All = [System.Collections.Specialized.OrderedDictionary]([System.StringComparer]::OrdinalIgnoreCase)
	Tasks = [System.Collections.Generic.List[object]]@()
	Errors = [System.Collections.Generic.List[object]]@()
	Warnings = [System.Collections.Generic.List[object]]@()
	Redefined = @()
	Doubles = @()
	Started = [DateTime]::Now
	Elapsed = $null
	Error = 'Invalid arguments.'
	Task = $null
	File = $BuildFile = $PSBoundParameters['File']
	Safe = $PSBoundParameters['Safe']
	Summary = $PSBoundParameters['Summary']
	CD = $OriginalLocation = *Path
	DP = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
	SP = @{}
	P = $p
	A = 1
	B = 0
	Q = 0
	H = @{}
	EnterBuild = $null
	ExitBuild = $null
	EnterTask = $null
	ExitTask = $null
	EnterJob = $null
	ExitJob = $null
	Header = if ($p) {$p.Header} else {{Write-Build 11 "Task $($args[0])"}}
	Footer = if ($p) {$p.Footer} else {{Write-Build 11 "Done $($args[0]) $($Task.Elapsed)"}}
	Data = @{}
	XBuild = $null
	XCheck = $null
})
if ($_ = $PSBoundParameters['Result']) {
	if ($_ -is [string]) {
		New-Variable $_ ${*} -Scope 1 -Force
	}
	elseif ($_ -is [hashtable]) {
		${*}.XBuild = $_['XBuild']
		${*}.XCheck = $_['XCheck']
		$_.Value = ${*}
	}
	else {throw 'Invalid parameter Result.'}
}
$BuildTask = $PSBoundParameters['Task']
if ($BuildFile -is [scriptblock]) {
	$BuildFile = $BuildFile.File
	return
}
if ($BuildTask -eq '**') {
	if (![System.IO.Directory]::Exists(($_ = *Path $BuildFile))) {throw "Missing directory '$_'."}
	$BuildFile = @(Get-ChildItem -LiteralPath $_ -Filter *.test.ps1 -Recurse -Force)
	return
}

if ($BuildFile) {
	if (![System.IO.File]::Exists(($BuildFile = *Path $BuildFile))) {
		if (![System.IO.Directory]::Exists($BuildFile)) {throw "Missing script '$BuildFile'."}
		if (!($_ = Get-BuildFile $BuildFile -Here)) {throw "Missing script in '$BuildFile'."}
		$BuildFile = $_
	}
}
elseif (!($BuildFile = Get-BuildFile ${*}.CD)) {
	throw 'Missing default script.'
}
${*}.File = $BuildFile

if (!($_ = (Get-Command $BuildFile -ErrorAction 1).Parameters)) {
	& $BuildFile
	throw 'Invalid script.'
}
if ($_.get_Count()) {
	$c = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'ErrorVariable', 'WarningVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable', 'InformationAction', 'InformationVariable', 'ProgressAction'
	$r = 'Task', 'File', 'Result', 'Safe', 'Summary', 'WhatIf'
	foreach($p in $_.get_Values()) {
		if ($c -contains ($_ = $p.Name)) {continue}
		if ($r -contains $_) {throw "Script uses reserved parameter '$_'."}
		foreach ($a in $p.Attributes) {
			if ($a -is [System.Management.Automation.ParameterAttribute] -and $a.Position -ge 0) {
				$a.Position += 2
			}
		}
		${*}.DP.Add($_, (New-Object System.Management.Automation.RuntimeDefinedParameter $_, $p.ParameterType, $p.Attributes))
	}
	${*}.DP
}

} end {

#.ExternalHelp Help.xml
function Add-BuildTask(
	[Parameter(Position=0, Mandatory=1)][string]$Name,
	[Parameter(Position=1)]$Jobs,
	[string[]]$After,
	[string[]]$Before,
	$If=-9,
	$Inputs,
	$Outputs,
	$Data,
	$Done,
	$Source=$MyInvocation,
	[switch]$Partial
)
{
	trap {*Die "Task '$Name': $_" 5}
	if (${*}.A -eq 0) {throw 'Cannot add tasks.'}
	if ($Jobs -is [hashtable]) {
		if ($PSBoundParameters.get_Count() -ne 2) {throw 'Invalid parameters.'}
		Add-BuildTask $Name @Jobs -Source:$Source
		return
	}
	if ($Name[0] -eq '?') {throw 'Invalid task name.'}
	if ($_ = ${*}.All[$Name]) {${*}.Redefined += $_}
	${*}.All[$Name] = [PSCustomObject]@{
		Name = $Name
		Error = $null
		Started = $null
		Elapsed = $null
		Jobs = $1 = [System.Collections.Generic.List[object]]@()
		After = $After
		Before = $Before
		If = $If
		Inputs = $Inputs
		Outputs = $Outputs
		Data = $Data
		Done = $Done
		Partial = $Partial
		InvocationInfo = $Source
	}
	if (!$Jobs) {return}
	$1.AddRange(@($Jobs))
	$2 = @()
	foreach($j in $1) {
		$r, $null = *Job $j
		if ($2 -contains $r) {${*}.Doubles += ,($Name, $r)}
		$2 += $r
	}
}

#.ExternalHelp Help.xml
function Assert-Build([Parameter()]$Condition, [string]$Message) {
	if (!$Condition) {
		*Die "Assertion failed.$(if ($Message) {" $Message"})" 7
	}
}

#.ExternalHelp Help.xml
function Assert-BuildEquals([Parameter()]$A, $B) {
	if (![Object]::Equals($A, $B)) {
		*Die @"
Objects are not equal:
A:$(if ($null -ne $A) {" $A [$($A.GetType())]"})
B:$(if ($null -ne $B) {" $B [$($B.GetType())]"})
"@ 7
	}
}

#.ExternalHelp Help.xml
function Get-BuildError([Parameter(Mandatory=1)][string]$Task) {
	if (!($_ = ${*}.All[$Task])) {
		*Die "Missing task '$Task'." 5
	}
	$_.Error
}

#.ExternalHelp Help.xml
function Get-BuildProperty([Parameter(Mandatory=1)][string]$Name, $Value) {
	${*n} = $Name
	${*v} = $Value
	Remove-Variable Name, Value
	if (($null -ne ($_ = $PSCmdlet.GetVariableValue(${*n})) -and '' -ne $_) -or ($_ = [Environment]::GetEnvironmentVariable(${*n}))) {return $_}
	if ($null -eq ${*v}) {*Die "Missing property '${*n}'." 13}
	${*v}
}

#.ExternalHelp Help.xml
function Get-BuildSynopsis([Parameter(Mandatory=1)]$Task, $Hash=${*}.H) {
	$f = ($I = $Task.InvocationInfo).ScriptName
	if (!($d = $Hash[$f])) {
		$Hash[$f] = $d = @{T = Get-Content -LiteralPath $f; C = @{}}
		foreach($_ in [System.Management.Automation.PSParser]::Tokenize($d.T, [ref]$null)) {
			if ($_.Type -eq 15) {$d.C[$_.EndLine] = $_.Content}
		}
	}
	for($n = $I.ScriptLineNumber; --$n -ge 1) {
		if ($c = $d.C[$n]) {if ($c -match '(?m)^\s*(?:#*\s*Synopsis\s*:|\.Synopsis\s*^)(.*)') {return $Matches[1].Trim()}}
		elseif ($d.T[$n - 1].Trim()) {break}
	}
}

#.ExternalHelp Help.xml
function Use-BuildEnv([Parameter(Mandatory=1)][hashtable]$Env, [Parameter(Mandatory=1)][scriptblock]$Script) {
	${private:*e} = @{}
	${private:*s} = $Script
	function *set($n, $v) {
		[Environment]::SetEnvironmentVariable($n, $(if ($null -eq $v) {[System.Management.Automation.Language.NullString]::Value} else {$v}))
	}
	foreach($_ in $Env.GetEnumerator()) {
		${*e}[$_.Key] = [Environment]::GetEnvironmentVariable($_.Key)
		*set $_.Key $_.Value
	}
	Remove-Variable Env, Script
	try {
		& ${*s}
	}
	finally {
		foreach($_ in ${*e}.GetEnumerator()) {
			*set $_.Key $_.Value
		}
	}
}

#.ExternalHelp Help.xml
function Invoke-BuildExec([Parameter(Mandatory=1)][scriptblock]$Command, [int[]]$ExitCode=0, [string]$ErrorMessage, [switch]$Echo, [switch]$StdErr) {
	${private:*c} = $Command
	${private:*x} = $ExitCode
	${private:*m} = $ErrorMessage
	${private:*v} = $Echo
	${private:*s} = $StdErr
	${private:*e} = ''
	Remove-Variable Command, ExitCode, ErrorMessage, Echo, StdErr
	if (${*v}) {
		*Echo ${*c}
	}

	$global:LastExitCode = 0
	if (${*s}) {
		$ErrorActionPreference = 2
		try {
			& ${*c} 2>&1 | .{process{
				if ($_ -is [System.Management.Automation.ErrorRecord]) {
					$_ = $_.Exception.Message
					${*e} += "`n$_"
				}
				$_
			}}
		}
		catch {throw}
	}
	else {
		& ${*c}
	}

	if (${*x} -notcontains $global:LastExitCode) {
		*Die "$(if (${*m}) {"${*m} "})Command exited with code $global:LastExitCode. {${*c}}${*e}" 8
	}
}

function *Echo {
	${*c} = $args[0]
	${*t} = "${*c}".Replace("`t", '    ')
	Write-Build 3 "exec {$(if (${*t} -match '((?:\r\n|[\r\n]) *)\S') {"$(${*t}.TrimEnd().Replace($matches[1], "`n    "))`n"} else {${*t}})}"
	Write-Build 8 "cd $global:pwd"
	foreach(${*v} in ${*c}.Ast.FindAll({$args[0] -is [System.Management.Automation.Language.VariableExpressionAst]}, $true)) {
		${*p} = ${*v}.Parent
		if (${*p} -is [System.Management.Automation.Language.MemberExpressionAst]) {
			if (${*p} -is [System.Management.Automation.Language.InvokeMemberExpressionAst]) {continue}
			${*v} = ${*p}
		}
		if (${*v}.Parent -isnot [System.Management.Automation.Language.AssignmentStatementAst]) {
			${*t} = "${*v}" -replace '^@', '$'
			Write-Build 8 "${*t}: $(& ([scriptblock]::Create(${*t})))"
		}
	}
}

#.ExternalHelp Help.xml
function Remove-BuildItem([Parameter(Mandatory=1)][string[]]$Path) {
	if ($Path -match '^[.*/\\]*$') {*Die 'Not allowed paths.' 5}
	$v = $PSBoundParameters['Verbose']
	try {
		foreach($_ in $Path) {
			if (Get-Item $_ -Force -ErrorAction 0) {
				if ($v) {Write-Verbose "remove: removing $_" -Verbose}
				Remove-Item $_ -Force -Recurse
			}
			elseif ($v) {Write-Verbose "remove: skipping $_" -Verbose}
		}
	}
	catch {
		*Die $_
	}
}

#.ExternalHelp Help.xml
function Test-BuildAsset(
	[ValidateNotNull()][string[]][Parameter(Position=0)]$Variable,
	[ValidateNotNull()][string[]]$Environment,
	[ValidateNotNull()][string[]]$Property,
	[ValidateNotNull()][string[]]$Path
) {
	Remove-Variable Variable, Environment, Property, Path
	function *get($p, $n) {
		if ($_ = $p[$n]) {
			$_ | .{process{if ($_) {$_} else {*Die "Invalid empty '$n'."}}}
		}
	}
	foreach($_ in *get $PSBoundParameters Variable) {
		if ($null -eq ($$ = $PSCmdlet.GetVariableValue($_)) -or '' -eq $$) {*Die "Missing variable '$_'." 13}
	}
	foreach($_ in *get $PSBoundParameters Environment) {
		if (!([Environment]::GetEnvironmentVariable($_))) {*Die "Missing environment variable '$_'." 13}
	}
	foreach($_ in *get $PSBoundParameters Property) {
		if ('' -eq (Get-BuildProperty $_ '')) {*Die "Missing property '$_'." 13}
	}
	foreach($_ in *get $PSBoundParameters Path) {
		if (!(Test-Path -LiteralPath $_)) {*Die "Missing path '$_'." 13}
	}
}

#.ExternalHelp Help.xml
function Use-BuildAlias([Parameter(Mandatory=1)][string]$Path, [string[]]$Name) {
	trap {*Die $_ 5}
	$d = switch -regex ($Path) {
		'^\*|^\d+\.' {Split-Path (Resolve-MSBuild $_)}
		^Framework {"$env:windir\Microsoft.NET\$_"}
		default {*Path $_}
	}
	if (![System.IO.Directory]::Exists($d)) {throw "Cannot resolve '$Path'."}
	foreach($_ in $Name) {
		Set-Alias $_ (Join-Path $d $_) -Scope 1
	}
}

#.ExternalHelp Help.xml
function Set-BuildFooter([Parameter()][scriptblock]$Script) {${*}.Footer = $Script}

#.ExternalHelp Help.xml
function Set-BuildHeader([Parameter()][scriptblock]$Script) {${*}.Header = $Script}

#.ExternalHelp Help.xml
function Confirm-Build([Parameter()][string]$Query, [string]$Caption=$Task.Name) {
	$PSCmdlet.ShouldContinue($Query, $Caption)
}

#.ExternalHelp Help.xml
function Write-Build([ConsoleColor]$Color, [string]$Text) {
	*Write $Color ($Text -split '\r\n|[\r\n]')
}

if ($PSVersionTable.PSVersion -ge [Version]'7.2' -and $PSStyle.OutputRendering -ne 'PlainText') {
	function *Write($C, $T) {
		$f = "`e[$((30,34,32,36,31,35,33,37,90,94,92,96,91,95,93,97)[$C])m{0}`e[0m"
		foreach($_ in $T) {
			$f -f $_
		}
	}
}
else {
	function *Write($C, $T) {
		$i = $Host.UI.RawUI
		$_ = $i.ForegroundColor
		try {
			$i.ForegroundColor = $C
			$T
		}
		finally {
			$i.ForegroundColor = $_
		}
	}
	try {
		$null = *Write 0
	}
	catch {
		function *Write {$args[1]}
	}
}

function *My {
	$_.InvocationInfo.ScriptName -eq $MyInvocation.ScriptName
}

function *SL($P=$BuildRoot) {
	Set-Location -LiteralPath $P -ErrorAction 1
}

function *Fin([Parameter()]$M, $C=0) {
	*Die $M $C
}

function *Run($_) {
	if ($_) {
		*SL
		. $_ @args
	}
}

function *At($I) {
	$I.InvocationInfo.PositionMessage.Trim()
}

function *Msg($M, $I) {
	"$M`n$(*At $I)"
}

function *Job($J) {
	if ($J -is [string]) {if ($J[0] -eq '?') {$J.Substring(1), 1} else {$J}}
	elseif ($J -is [scriptblock]) {$J}
	else {*Fin 'Invalid job.' 5}
}

function *Unsafe($N, $J) {
	if ($J -contains $N) {return 1}
	foreach($_ in $J) {
		$r, $null = *Job $_
		if ($r -ne $N -and ($t = ${*}.All[$r]) -and $t.If -and (*Unsafe $N $t.Jobs)) {
			return 1
		}
	}
}

function *Amend($X, $J, $B) {
	$n = $X.Name
	foreach($_ in $J) {
		$r, $s = *Job $_
		if (!($t = ${*}.All[$r])) {*Fin (*Msg "Task '$n': Missing task '$r'." $X) 5}
		$j = $t.Jobs
		$i = $j.Count
		if ($B) {
			for($k = -1; ++$k -lt $i -and $j[$k] -is [string]) {}
			$i = $k
		}
		$j.Insert($i, $(if ($s) {"?$n"} else {$n}))
	}
}

function *Check($J, $T, $P=@()) {
	foreach($_ in $J) { if ($_ -is [string]) {
		$_, $null = *Job $_
		if (!($r = ${*}.All[$_])) {
			$_ = "Missing task '$_'."
			*Fin $(if ($T) {*Msg "Task '$($T.Name)': $_" $T} else {$_}) 5
		}
		if ($P -contains $r) {
			*Fin (*Msg "Task '$($T.Name)': Cyclic reference to '$_'." $T) 5
		}
		*Check $r.Jobs $r ($P + $r)
	}}
}

filter *Help {
	$r = 1 | Select-Object Name, Jobs, Synopsis
	$r.Name = $_.Name
	$r.Jobs = foreach($j in $_.Jobs) {if ($j -is [string]) {$j} else {'{}'}}
	$r.Synopsis = Get-BuildSynopsis $_
	$r
}

function *Root($A) {
	*Check $A.get_Keys()
	$h = @{}
	foreach($_ in $A.get_Values()) {foreach($_ in $_.Jobs) {
		if ($_ -is [string]) {
			$_, $null = *Job $_
			$h[$_] = 1
		}
	}}
	foreach($_ in $A.get_Keys()) {if (!$h[$_]) {$_}}
}

function *Err($T) {
	${*}.Errors.Add([PSCustomObject]@{Error = $_; File = $BuildFile; Task = $T})
	Write-Build 12 "ERROR: $(if (*My) {$_} else {*Msg $_ $_})"
	if ($T) {$T.Error = $_}
}

function *IO {
	if ((${private:*i} = $Task.Inputs) -is [scriptblock]) {
		*SL
		${*i} = @(& ${*i})
	}
	*SL
	${private:*p} = [System.Collections.Generic.List[object]]@()
	${*i} = foreach($_ in ${*i}) {
		if ($_ -isnot [System.IO.FileInfo]) {$_ = [System.IO.FileInfo](*Path $_)}
		if (!$_.Exists) {*Fin "Missing input '$_'." 13}
		${*p}.Add($_.FullName)
		$_
	}
	if (!${*p}) {return 2, 'Skipping empty input.'}

	${private:*o} = $Task.Outputs
	if ($Task.Partial) {
		${*o} = @(
			if (${*o} -is [scriptblock]) {
				${*p} | & ${*o}
				*SL
			}
			else {
				${*o}
			}
		)
		if (${*p}.Count -ne ${*o}.Count) {*Fin "Different Inputs/Outputs counts: $(${*p}.Count)/$(${*o}.Count)." 6}

		$k = -1
		$Task.Inputs = $i = [System.Collections.Generic.List[object]]@()
		$Task.Outputs = $o = [System.Collections.Generic.List[object]]@()
		foreach($_ in ${*i}) {
			$f = *Path ($p = ${*o}[++$k])
			if (![System.IO.File]::Exists($f) -or $_.LastWriteTime -gt [System.IO.File]::GetLastWriteTime($f)) {
				$i.Add(${*p}[$k])
				$o.Add($p)
			}
		}
		if ($i) {return $null, "Out-of-date outputs: $($o.Count)/$(${*p}.Count)."}
	}
	else {
		if (${*o} -is [scriptblock]) {
			$Task.Outputs = ${*o} = ${*p} | & ${*o}
			*SL
		}
		if (!${*o}) {*Fin 'Outputs must not be empty.' 5}

		$Task.Inputs = ${*p}
		$m = (${*i} | .{process{$_.LastWriteTime.Ticks}} | Measure-Object -Maximum).Maximum
		foreach($_ in ${*o}) {
			$p = *Path $_
			if (![System.IO.File]::Exists($p)) {return $null, "Missing output '$_'."}
			if ($m -gt [System.IO.File]::GetLastWriteTime($p).Ticks) {return $null, "Out-of-date output '$_'."}
		}
	}
	2, 'Skipping up-to-date output.'
}

function *Task {
	${private:*p} = "$($args[1])/$($args[0])"
	${private:*n}, ${private:*s} = *Job $args[0]
	New-Variable Task (${*}.Task = ${*}.All[${*n}]) -Option Constant

	if ($Task.Elapsed) {
		Write-Build 8 "Done ${*p}"
		return
	}

	$Task.Started = [DateTime]::Now
	if ((${private:*x} = $Task.If) -is [scriptblock]) {
		*SL
		try {
			${*x} = & ${*x}
		}
		catch {
			*Err $Task
			Write-Build 8 (*At $Task)
			${*}.Tasks.Add($Task)
			$Task.Elapsed = [TimeSpan]::Zero
			throw
		}
	}
	if (!${*x}) {
		Write-Build 8 "Task ${*p} skipped."
		return
	}

	${private:*i} = , [int]($null -ne $Task.Inputs)
	try {
		. *Run ${*}.EnterTask
		foreach($_ in $Task.Jobs) {
			if ($_ -is [string]) {
				try {
					*Task $_ ${*p}
				}
				finally {
					${*}.Task = $Task
				}
				continue
			}
			New-Variable Job $_ -Option ReadOnly -Force
			& ${*}.Header ${*p}

			if (1 -eq ${*i}[0]) {
				try {
					${*i} = *IO
				}
				catch {
					*Err $Task
					throw
				}
				Write-Build 8 ${*i}[1]
			}
			if (${*i}[0]) {
				continue
			}

			try {
				. *Run ${*}.EnterJob
				*SL
				if (0 -eq ${*i}[0]) {
					& $Job
				}
				else {
					$Inputs = $Task.Inputs
					$Outputs = $Task.Outputs
					if ($Task.Partial) {
						${*x} = 0
						$Inputs | .{process{
							$2 = $Outputs[${*x}++]
							$_
						}} | & $Job
					}
					else {
						$Inputs | & $Job
					}
				}
			}
			catch {
				*Err $Task
				Write-Build 8 (*At $Task)
				throw
			}
			finally {
				. *Run ${*}.ExitJob
			}
		}
	}
	catch {
		$Task.Error = $_
		if (!${*s} -or (*Unsafe ${*n} $BuildTask)) {throw}
	}
	finally {
		$Task.Elapsed = [DateTime]::Now - $Task.Started
		${*}.Tasks.Add($Task)
		if (!$Task.Error) {
			if (${*}.XCheck) {& ${*}.XCheck}
			& ${*}.Footer ${*p}
		}
		*Run $Task.Done
		. *Run ${*}.ExitTask
	}
}

Set-Alias assert Assert-Build
Set-Alias equals Assert-BuildEquals
Set-Alias exec Invoke-BuildExec
Set-Alias property Get-BuildProperty
Set-Alias remove Remove-BuildItem
Set-Alias requires Test-BuildAsset
Set-Alias task Add-BuildTask
Set-Alias use Use-BuildAlias
Set-Alias Invoke-Build ($_ = $MyInvocation.MyCommand.Path)
$_ = Split-Path $_
Set-Alias Show-TaskHelp (Join-Path $_ Show-TaskHelp.ps1)
Set-Alias Build-Parallel (Join-Path $_ Build-Parallel.ps1)
Set-Alias Resolve-MSBuild (Join-Path $_ Resolve-MSBuild.ps1)

if ($MyInvocation.InvocationName -eq '.') {
	Remove-Variable Task, File, Result, Safe, Summary, WhatIf
	return
}

function Write-Warning([Parameter()]$Message) {
	$PSCmdlet.WriteWarning($Message)
	${*}.Warnings.Add([PSCustomObject]@{Message = $Message; File = $BuildFile; Task = ${*}.Task; InvocationInfo=$MyInvocation})
}

$ErrorActionPreference = 1
foreach($_ in ${*}.DP.get_Values()) {
	if ($_.IsSet) {
		${*}.SP[$_.Name] = $_.Value
	}
}
if (${*}.Q = $BuildTask -eq '?' -or $BuildTask -eq '??') {
	$WhatIf = $true
}
Remove-Variable Task, File, Result, Safe, Summary, p, c, r, a

${*}.Error = $null
try {
	if ($BuildTask -eq '**') {
		${*}.A = 0
		foreach($_ in $BuildFile) {
			Invoke-Build * $_.FullName -Safe:${*}.Safe
		}
		${*}.B = 1
		exit
	}

	function Enter-Build([Parameter()][scriptblock]$Script) {${*}.EnterBuild = $Script}
	function Exit-Build([Parameter()][scriptblock]$Script) {${*}.ExitBuild = $Script}
	function Enter-BuildTask([Parameter()][scriptblock]$Script) {${*}.EnterTask = $Script}
	function Exit-BuildTask([Parameter()][scriptblock]$Script) {${*}.ExitTask = $Script}
	function Enter-BuildJob([Parameter()][scriptblock]$Script) {${*}.EnterJob = $Script}
	function Exit-BuildJob([Parameter()][scriptblock]$Script) {${*}.ExitJob = $Script}
	function Set-BuildData([Parameter()]$Key, $Value) {${*}.Data[$Key] = $Value}

	*SL ($BuildRoot = if ($BuildFile) {Split-Path $BuildFile} else {${*}.CD})
	New-Variable Task @{Name = $BuildFile} -Option Constant
	$_ = ${*}.SP
	${private:**} = @(. ${*}.File @_)
	foreach($_ in ${**}) {
		Write-Warning "Unexpected output: $_."
		if ($_ -is [scriptblock]) {*Fin "Dangling scriptblock at $($_.File):$($_.StartPosition.StartLine)" 6}
	}
	if (!(${**} = ${*}.All).get_Count()) {*Fin "No tasks in '$BuildFile'." 6}

	foreach($_ in ${**}.get_Values()) {
		if ($_.Before) {*Amend $_ $_.Before 1}
	}
	foreach($_ in ${**}.get_Values()) {
		if ($_.After) {*Amend $_ $_.After}
	}

	if (${*}.Q) {
		*Check ${**}.get_Keys()
		if ($BuildTask -eq '?') {
			${**}.get_Values() | *Help
		}
		else {
			${**}
		}
		exit
	}

	if ($BuildTask -eq '*') {
		$BuildTask = *Root ${**}
	}
	else {
		if (!$BuildTask -or '.' -eq $BuildTask) {
			$BuildTask = if (${**}['.']) {'.'} else {${**}.Item(0).Name}
		}
		*Check $BuildTask
	}
	if ($WhatIf) {
		Show-TaskHelp
		exit
	}

	New-Variable BuildRoot (*Path $BuildRoot) -Option Constant -Force
	if (![System.IO.Directory]::Exists($BuildRoot)) {*Fin "Missing build root '$BuildRoot'." 13}

	Write-Build 11 "Build $($BuildTask -join ', ') $BuildFile"
	foreach($_ in ${*}.Redefined) {
		Write-Build 8 "Redefined task '$($_.Name)'."
	}
	foreach($_ in ${*}.Doubles) {
		if (${*}.All[$_[1]].If -isnot [scriptblock]) {
			Write-Warning "Task '$($_[0])' always skips '$($_[1])'."
		}
	}

	${*}.A = 0
	try {
		. *Run ${*}.EnterBuild
		if (${*}.XBuild) {. ${*}.XBuild}
		if (${*}.XCheck) {& ${*}.XCheck}
		foreach($_ in $BuildTask) {
			*Task $_ ''
		}
	}
	finally {
		${*}.Task = $null
		. *Run ${*}.ExitBuild
	}
	${*}.B = 1
	exit
}
catch {
	${*}.B = 2
	${*}.Error = $_
	if (!${*}.Errors) {*Err}
	if ($_.FullyQualifiedErrorId -eq 'PositionalParameterNotFound,Add-BuildTask') {
		Write-Warning 'Check task parameters: Name and comma separated Jobs.'
	}
	if (${*}.Safe) {
		exit
	}
	elseif (*My) {
		$PSCmdlet.ThrowTerminatingError($_)
	}
	throw
}
finally {
	*SL ${*}.CD
	if (${*}.B -and !${*}.Q) {
		$t = ${*}.Tasks
		$e = ${*}.Errors
		if (${*}.Summary) {
			Write-Build 11 'Build summary:'
			foreach($_ in $t) {
				'{0,-16} {1} - {2}:{3}' -f $_.Elapsed, $_.Name, $_.InvocationInfo.ScriptName, $_.InvocationInfo.ScriptLineNumber
				if ($_ = $_.Error) {
					Write-Build 12 "ERROR: $(if (*My) {$_} else {*Msg $_ $_})"
				}
			}
		}
		if ($w = ${*}.Warnings) {
			foreach($_ in $w) {
				"WARNING: $(if ($_.Task) {"/$($_.Task.Name) "})$($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber)"
				Write-Build 14 $_.Message
			}
		}
		if ($_ = ${*}.P) {
			$_.Tasks.AddRange($t)
			$_.Errors.AddRange($e)
			$_.Warnings.AddRange($w)
		}
		$c, $m = if (${*}.A) {12, "Build ABORTED $BuildFile"}
		elseif (${*}.B -eq 2) {12, 'Build FAILED'}
		elseif ($e) {14, 'Build completed with errors'}
		elseif ($w) {14, 'Build succeeded with warnings'}
		else {10, 'Build succeeded'}
		Write-Build $c "$m. $($t.Count) tasks, $($e.Count) errors, $($w.Count) warnings $((${*}.Elapsed = [DateTime]::Now - ${*}.Started))"
	}
}
}
tools\InvokeBuild\5.12.1\InvokeBuild.psd1
@{
	ModuleVersion = '5.12.1'
	ModuleToProcess = 'InvokeBuild.psm1'
	GUID = 'a0319025-5f1f-47f0-ae8d-9c7e151a5aae'
	Author = 'Roman Kuzmin'
	CompanyName = 'Roman Kuzmin'
	Copyright = '(c) Roman Kuzmin'
	Description = 'Build and test automation in PowerShell'
	PowerShellVersion = '3.0'
	AliasesToExport = 'Invoke-Build', 'Build-Checkpoint', 'Build-Parallel'
	PrivateData = @{
		PSData = @{
			Tags = 'Build', 'Test', 'Automation'
			ProjectUri = 'https://github.com/nightroman/Invoke-Build'
			LicenseUri = 'http://www.apache.org/licenses/LICENSE-2.0'
			IconUri = 'https://raw.githubusercontent.com/nightroman/Invoke-Build/main/ib.png'
			ReleaseNotes = 'https://github.com/nightroman/Invoke-Build/blob/main/Release-Notes.md'
		}
	}
}
tools\InvokeBuild\5.12.1\InvokeBuild.psm1

Set-Alias -Name Build-Checkpoint -Value (Join-Path $PSScriptRoot Build-Checkpoint.ps1)
Set-Alias -Name Build-Parallel -Value (Join-Path $PSScriptRoot Build-Parallel.ps1)
Set-Alias -Name Invoke-Build -Value (Join-Path $PSScriptRoot Invoke-Build.ps1)
Export-ModuleMember -Alias Build-Checkpoint, Build-Parallel, Invoke-Build
tools\InvokeBuild\5.12.1\LICENSE
 
tools\InvokeBuild\5.12.1\PSGetModuleInfo.xml
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <Obj RefId="0">
    <TN RefId="0">
      <T>Microsoft.PowerShell.Commands.PSRepositoryItemInfo</T>
      <T>System.Management.Automation.PSCustomObject</T>
      <T>System.Object</T>
    </TN>
    <MS>
      <S N="Name">InvokeBuild</S>
      <S N="Version">5.12.1</S>
      <S N="Type">Module</S>
      <S N="Description">Build and test automation in PowerShell</S>
      <S N="Author">Roman Kuzmin</S>
      <S N="CompanyName">nightroman</S>
      <S N="Copyright">(c) Roman Kuzmin</S>
      <DT N="PublishedDate">2024-11-27T12:04:56+00:00</DT>
      <Nil N="InstalledDate" />
      <Nil N="UpdatedDate" />
      <URI N="LicenseUri">http://www.apache.org/licenses/LICENSE-2.0</URI>
      <URI N="ProjectUri">https://github.com/nightroman/Invoke-Build</URI>
      <URI N="IconUri">https://raw.githubusercontent.com/nightroman/Invoke-Build/main/ib.png</URI>
      <Obj N="Tags" RefId="1">
        <TN RefId="1">
          <T>System.Object[]</T>
          <T>System.Array</T>
          <T>System.Object</T>
        </TN>
        <LST>
          <S>Build</S>
          <S>Test</S>
          <S>Automation</S>
          <S>PSModule</S>
        </LST>
      </Obj>
      <Obj N="Includes" RefId="2">
        <TN RefId="2">
          <T>System.Collections.Hashtable</T>
          <T>System.Object</T>
        </TN>
        <DCT>
          <En>
            <S N="Key">Function</S>
            <Obj N="Value" RefId="3">
              <TNRef RefId="1" />
              <LST />
            </Obj>
          </En>
          <En>
            <S N="Key">RoleCapability</S>
            <Obj N="Value" RefId="4">
              <TNRef RefId="1" />
              <LST />
            </Obj>
          </En>
          <En>
            <S N="Key">Command</S>
            <Obj N="Value" RefId="5">
              <TNRef RefId="1" />
              <LST />
            </Obj>
          </En>
          <En>
            <S N="Key">DscResource</S>
            <Obj N="Value" RefId="6">
              <TNRef RefId="1" />
              <LST />
            </Obj>
          </En>
          <En>
            <S N="Key">Workflow</S>
            <Obj N="Value" RefId="7">
              <TNRef RefId="1" />
              <LST />
            </Obj>
          </En>
          <En>
            <S N="Key">Cmdlet</S>
            <Obj N="Value" RefId="8">
              <TNRef RefId="1" />
              <LST />
            </Obj>
          </En>
        </DCT>
      </Obj>
      <Nil N="PowerShellGetFormatVersion" />
      <S N="ReleaseNotes">https://github.com/nightroman/Invoke-Build/blob/main/Release-Notes.md</S>
      <Obj N="Dependencies" RefId="9">
        <TNRef RefId="1" />
        <LST />
      </Obj>
      <S N="RepositorySourceLocation">https://www.powershellgallery.com/api/v2</S>
      <S N="Repository">PSGallery</S>
      <S N="PackageManagementProvider">NuGet</S>
      <Obj N="AdditionalMetadata" RefId="10">
        <TN RefId="3">
          <T>System.Management.Automation.PSCustomObject</T>
          <T>System.Object</T>
        </TN>
        <MS>
          <S N="copyright">(c) Roman Kuzmin</S>
          <S N="description">Build and test automation in PowerShell</S>
          <S N="requireLicenseAcceptance">False</S>
          <S N="releaseNotes">https://github.com/nightroman/Invoke-Build/blob/main/Release-Notes.md</S>
          <S N="isLatestVersion">True</S>
          <S N="isAbsoluteLatestVersion">True</S>
          <S N="versionDownloadCount">225</S>
          <S N="downloadCount">2073246</S>
          <S N="packageSize">41069</S>
          <S N="published">11/27/2024 12:04:56 PM +00:00</S>
          <S N="created">11/27/2024 12:04:56 PM +00:00</S>
          <S N="lastUpdated">11/27/2024 3:00:00 PM +00:00</S>
          <S N="tags">Build Test Automation PSModule</S>
          <S N="developmentDependency">False</S>
          <S N="updated">2024-11-27T15:00:00Z</S>
          <S N="NormalizedVersion">5.12.1</S>
          <S N="Authors">Roman Kuzmin</S>
          <S N="IsPrerelease">false</S>
          <S N="ItemType">Module</S>
          <S N="FileList">InvokeBuild.nuspec|Help.xml|Invoke-Build.ps1|InvokeBuild.psd1|InvokeBuild.psm1|LICENSE|README.htm|Resolve-MSBuild.ps1|Show-TaskHelp.ps1|about_InvokeBuild.help.txt|Build-Checkpoint.ps1|Build-Parallel.ps1</S>
          <S N="GUID">a0319025-5f1f-47f0-ae8d-9c7e151a5aae</S>
          <S N="PowerShellVersion">3.0</S>
          <S N="CompanyName">Roman Kuzmin</S>
        </MS>
      </Obj>
      <S N="InstalledLocation">C:\projects\au-packages\invoke-build\tools\InvokeBuild\5.12.1</S>
    </MS>
  </Obj>
</Objs>
tools\InvokeBuild\5.12.1\README.htm
 
tools\InvokeBuild\5.12.1\Resolve-MSBuild.ps1
<#PSScriptInfo
.VERSION 1.6.2
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.TAGS Invoke-Build, MSBuild
.GUID 53c01926-4fc5-4cbd-aa46-32e415b2373b
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>

<#
.Synopsis
	Finds the specified or latest MSBuild.

.Description
	The script finds the path to the specified or latest version of MSBuild.
	It is designed for MSBuild 17.0, 16.0, 15.0, 14.0, 12.0, 4.0, 3.5, 2.0.

	For MSBuild 15+ the command uses the module VSSetup, see PSGallery.
	If VSSetup is not installed then the default locations are used.
	VSSetup is required for not default installations.

	MSBuild 15+ resolution: the latest major version (or absolute if -Latest),
	then Enterprise, Professional, Community, BuildTools, other products.

	For MSBuild 2.0-14.0 the information is taken from the registry.

.Parameter Version
		Specifies the required MSBuild major version. If it is omitted, empty,
		or *, then the command finds and returns the latest installed version.
		The optional suffix x86 tells to use 32-bit MSBuild.
		Versions: 17.0, 16.0, 15.0, 14.0, 12.0, 4.0, 3.5, 2.0.

.Parameter MinimumVersion
		Specifies the required minimum MSBuild version. If the resolved version
		is less than the minimum then the commands terminates with an error.

.Parameter Latest
		Tells to select the latest minor version if there are 2+ products with
		the same major version. Note that major versions have higher precedence
		than products regardless of -Latest.

.Outputs
	The full path to MSBuild.exe

.Example
	Resolve-MSBuild 17.0x86
	Gets the location of 32-bit MSBuild of Visual Studio 2022.

.Example
	Resolve-MSBuild -MinimumVersion 16.3.1 -Latest
	Gets the location of the latest MSBuild, and asserts its version is 16.3.1+.

.Example
	Resolve-MSBuild x86 -MinimumVersion 15.0 -Latest
	Gets the location of the latest 32-bit MSBuild, and asserts its version is 15.0+.

.Link
	https://www.powershellgallery.com/packages/VSSetup
#>

[OutputType([string])]
[CmdletBinding()]
param(
	[string]$Version
	,
	[Version]$MinimumVersion
	,
	[switch]$Latest
)

function Get-MSBuild15Path {
	[CmdletBinding()] param(
		[string]$Version,
		[string]$Bitness
	)

	if ([System.IntPtr]::Size -eq 4 -or $Bitness -eq 'x86') {
		"MSBuild\$Version\Bin\MSBuild.exe"
	}
	else {
		"MSBuild\$Version\Bin\amd64\MSBuild.exe"
	}
}

function Get-MSBuild15VSSetup {
	[CmdletBinding()] param(
		[string]$Version,
		[string]$Bitness,
		[switch]$Latest,
		[switch]$Prerelease
	)

	if (!(Get-Module VSSetup)) {
		if (!(Get-Module VSSetup -ListAvailable)) {return}
		Import-Module VSSetup
	}

	$items = @(
		$v = switch($Version) {
			'17.0' {'[17.0,18.0)'}
			'16.0' {'[16.0,17.0)'}
			'15.0' {'[15.0,16.0)'}
			default {'[15.0,)'}
		}
		Get-VSSetupInstance -Prerelease:$Prerelease |
		Select-VSSetupInstance -Version $v -Require Microsoft.Component.MSBuild -Product *
	)
	if (!$items) {
		if (!$Prerelease) {
			Get-MSBuild15VSSetup $Version $Bitness -Latest:$Latest -Prerelease
		}
		return
	}

	if ($items.Count -ge 2) {
		$byVersion = if ($Latest) {{$_.InstallationVersion}} else {{$_.InstallationVersion.Major}}
		$byProduct = {
			switch ($_.Product.Id) {
				Microsoft.VisualStudio.Product.Enterprise {4}
				Microsoft.VisualStudio.Product.Professional {3}
				Microsoft.VisualStudio.Product.Community {2}
				Microsoft.VisualStudio.Product.BuildTools {1}
				default {0}
			}
		}
		$items = $items | Sort-Object $byVersion, $byProduct
	}

	$item = $items[-1]
	if ($item.InstallationVersion.Major -eq 15) {
		$Version = '15.0'
	}
	else {
		$Version = 'Current'
	}
	Join-Path $item.InstallationPath (Get-MSBuild15Path $Version $Bitness)
}

function Get-MSBuild15Guess {
	[CmdletBinding()] param(
		[string]$Version,
		[string]$Bitness,
		[switch]$Latest,
		[switch]$Prerelease
	)

	$Program64 = $env:ProgramFiles
	if (!($Program86 = ${env:ProgramFiles(x86)})) {$Program86 = $Program64}

	$folders = $(
		if ($Prerelease) {
			"$Program64\Microsoft Visual Studio\Preview"
			"$Program86\Microsoft Visual Studio\Preview"
		}
		elseif ($Version -eq '*') {
			"$Program64\Microsoft Visual Studio\2022"
			"$Program86\Microsoft Visual Studio\2022"
			"$Program86\Microsoft Visual Studio\2019"
			"$Program86\Microsoft Visual Studio\2017"
		}
		elseif ($Version -eq '17.0') {
			"$Program64\Microsoft Visual Studio\2022"
			"$Program86\Microsoft Visual Studio\2022"
		}
		elseif ($Version -eq '16.0') {
			"$Program86\Microsoft Visual Studio\2019"
		}
		else {
			"$Program86\Microsoft Visual Studio\2017"
		}
	)
	foreach($folder in $folders) {
		$items = @(Get-Item -ErrorAction 0 @(
			"$folder\*\$(Get-MSBuild15Path Current $Bitness)"
			"$folder\*\$(Get-MSBuild15Path $Version $Bitness)"
		))
		if ($items) {
			break
		}
	}
	if (!$items) {
		if (!$Prerelease) {
			Get-MSBuild15Guess $Version $Bitness -Latest:$Latest -Prerelease
		}
		return
	}

	if ($items.Count -ge 2) {
		$byVersion = if ($Latest) {{[Version]$_.VersionInfo.FileVersion}} else {{([Version]$_.VersionInfo.FileVersion).Major}}
		$byProduct = {
			switch -Wildcard ($_.FullName) {
				*\Enterprise\* {4}
				*\Professional\* {3}
				*\Community\* {2}
				*\BuildTools\* {1}
				default {0}
			}
		}
		$items = $items | Sort-Object $byVersion, $byProduct
	}

	$items[-1].FullName
}

function Get-MSBuild15 {
	[CmdletBinding()] param(
		[string]$Version,
		[string]$Bitness,
		[switch]$Latest
	)

	if ($path = Get-MSBuild15VSSetup $Version $Bitness -Latest:$Latest) {
		$path
	}
	else {
		Get-MSBuild15Guess $Version $Bitness -Latest:$Latest
	}
}

function Get-MSBuildOldVersion {
	[CmdletBinding()] param(
		[string]$Version,
		[string]$Bitness
	)

	if ([System.IntPtr]::Size -eq 8 -and $Bitness -eq 'x86') {
		$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\$Version"
	}
	else {
		$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$Version"
	}
	$rp = [Microsoft.Win32.Registry]::GetValue($key, 'MSBuildToolsPath', '')
	if ($rp) {
		Join-Path $rp MSBuild.exe
	}
}

function Get-MSBuildOldLatest {
	[CmdletBinding()] param(
		[string]$Bitness
	)

	$rp = @(Get-ChildItem HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions | Sort-Object {[Version]$_.PSChildName})
	if ($rp) {
		Get-MSBuildOldVersion $rp[-1].PSChildName $Bitness
	}
}

function Get-MSBuildAny {
	[CmdletBinding()] param(
		[string]$Bitness,
		[switch]$Latest
	)

	if ($path = Get-MSBuild15 * $Bitness -Latest:$Latest) {
		$path
	}
	else {
		Get-MSBuildOldLatest $Bitness
	}
}

$ErrorActionPreference = 1

if ($Version -match '^(.*?)x86\s*$') {
	$Version = $Matches[1]
	$Bitness = 'x86'
}
else {
	$Bitness = ''
}
$Version = $Version.Trim()
if (!$Version) {
	$Version = '*'
}

$v17 = [Version]'17.0'
$v16 = [Version]'16.0'
$v15 = [Version]'15.0'
$vMax = [Version]'9999.0'

if ($Version -eq '*') {
	$vRequired = $vMax
}
else {
	try {
		$vRequired = [Version]$Version
	}
	catch {
		Write-Error "Invalid MSBuild version format: $Version."
	}
}

$path = ''
if ($vRequired -eq $v17 -or $vRequired -eq $v16 -or $vRequired -eq $v15) {
	$path = Get-MSBuild15 $Version $Bitness -Latest:$Latest
}
elseif ($vRequired -lt $v15) {
	$path = Get-MSBuildOldVersion $Version $Bitness
}
elseif ($vRequired -eq $vMax) {
	$path = Get-MSBuildAny $Bitness -Latest:$Latest
}

if (!$path) {
	Write-Error "Cannot find MSBuild version: $Version."
}

if ($MinimumVersion) {
	$vResolved = [Version](& $path -version -nologo)
	if ($vResolved -lt $MinimumVersion) {
		Write-Error "MSBuild resolved version $vResolved is less than required minimum $MinimumVersion."
	}
}

$path
tools\InvokeBuild\5.12.1\Show-TaskHelp.ps1
<#
.Synopsis
	Shows Invoke-Build task help information.
	Copyright (c) Roman Kuzmin

.Description
	The command shows the specified tasks help information as task names with
	synopses, jobs with their locations, script parameters and environment. By
	default, it analyses the code in order to extract variables in addition to
	optionally documented in comments.

	Synopsis is defined in task comments as # Synopsis: ...
	Parameters are defined as # Parameters: name1, name2, ...
	Environment variables are defined as # Environment: name1, name2, ...

	Parameters names match build parameters and separated by spaces or commas.
	Parameter descriptions are taken from the build script comment based help.

	Help info members (for custom formatters):

		Task: [object[]] Tasks to do.
			Name: [string] Task name.
			Synopsis: [string] Task synopsis, may be null.
		Jobs: [object[]] Jobs to do.
			Name: [string] Task name.
			Location: [string] Task location as "<file>:<line>".
		Parameters: [object[]] Tasks parameters, may be empty.
			Name: [string] Parameter name.
			Type: [string] Parameter type.
			Description: [string] Parameter help, may be null or empty.
		Environment: [string[]] Tasks environment variables, may be empty.

.Parameter Task
		Build task name(s). The default is the usual default task.

.Parameter File
		Build script path. The default is the usual default script.

.Parameter NoCode
		Tells to skip code analysis for parameters and environment.
		It is used as true for PowerShell v2.

.Parameter Format
		Specifies the custom task help formatter.

.Link
	https://github.com/nightroman/Invoke-Build
#>

param(
	[Parameter(Position=0)][string[]]$Task
	,
	[Parameter(Position=1)]$File
	,
	[object]$Format = 'Format-TaskHelp'
	,
	[switch]$NoCode
)

trap {$PSCmdlet.ThrowTerminatingError($_)}
$ErrorActionPreference = 1

if ([System.IO.Path]::GetFileName($MyInvocation.ScriptName) -eq 'Invoke-Build.ps1') {
	$all = ${*}.All
	Remove-Variable Task
}
else {
	$BuildTask = $Task
	$BuildFile = $File
	. Invoke-Build

	### resolve file
	if ($BuildFile) {
		$BuildFile = *Path $BuildFile
		if (![System.IO.File]::Exists($BuildFile)) {*Fin "Missing file '$BuildFile'." 5}
	}
	else {
		$BuildFile = Get-BuildFile (*Path)
		if (!$BuildFile) {*Fin 'Missing default script.' 5}
	}

	### resolve task
	$all = Invoke-Build ?? $BuildFile
	if (!$BuildTask -or '.' -eq $BuildTask) {
		$BuildTask = if ($all['.']) {'.'} else {$all.Item(0).Name}
	}
}

### get script parameter help
$Help = @(&{
	Set-StrictMode -Off
	if ($r = Get-Help $BuildFile) {if ($r = $r.parameters) {if ($r = $r.parameter) {$r}}}
})

### get script parameters
$CommonParameters = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'ErrorVariable', 'WarningVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable', 'InformationAction', 'InformationVariable'
$Parameters = (Get-Command $BuildFile).Parameters
foreach($name in @($Parameters.get_Keys())) {
	if ($CommonParameters -contains $name) {
		$null = $Parameters.Remove($name)
	}
}

# amend options
$NoCode = $NoCode -or $PSVersionTable.PSVersion.Major -le 2

# globals
$Hash = @{}
$BuildJobs = @()
$MapParameter = @{}
$MapEnvironment = @{}

# collect jobs to do in $BuildJobs
function Add-TaskJob($Jobs, $Task) {
	foreach($job in $Jobs) {
		$job, $null = *Job $job
		if ($job -is [string]) {
			$task2 = $all[$job]
			Add-TaskJob $task2.Jobs $task2
		}
		else {
			if ($BuildJobs -notcontains $Task.Name) {
				$script:BuildJobs += $Task.Name
			}
		}
	}

	if ($Task -and $Task.If -is [scriptblock]) {
		if ($BuildJobs -notcontains $Task.Name) {
			$script:BuildJobs += $Task.Name
		}
	}
}

# get parameters and environment from comments
function Get-TaskComment($Task) {
	$f = ($I = $Task.InvocationInfo).ScriptName
	if (!($d = $Hash[$f])) {
		$Hash[$f] = $d = @{T = Get-Content -LiteralPath $f; C = @{}}
		foreach($_ in [System.Management.Automation.PSParser]::Tokenize($d.T, [ref]$null)) {
			if ($_.Type -eq 15) {$d.C[$_.EndLine] = $_.Content}
		}
	}
	$r = @{Parameters = @(); Environment = @()}
	for($n = $I.ScriptLineNumber; --$n -ge 1) {
		if ($c = $d.C[$n]) {
			if ($c -match '(?m)^\s*#*\s*Parameters\s*:(.*)') {$r.Parameters = $Matches[1].Trim() -split '[\s,]+'}
			elseif ($c -match '(?m)^\s*#*\s*Environment\s*:(.*)') {$r.Environment = $Matches[1].Trim() -split '[\s,]+'}
		}
		elseif ($d.T[$n - 1].Trim()) {
			break
		}
	}
	$r
}

function Add-VariablePath($Path) {
	$index = $Path.IndexOf(':')
	if ($index -ge 0) {
		$prefix = $Path.Substring(0, $index)
		$name = $Path.Substring($index + 1)
	}
	else {
		$prefix = ''
		$name = $Path
	}
	if (!$prefix -or $prefix -eq 'script') {
		if ($Parameters.ContainsKey($name)) {
			$MapParameter[$name] = 1
		}
	}
	elseif ($prefix -eq 'env') {
		$MapEnvironment[$name] = 1
	}
}

function Add-BlockVariable($Block) {
	foreach($variable in $Block.Ast.FindAll({$args[0] -is [System.Management.Automation.Language.VariableExpressionAst]}, $true)) {
		if ($variable.Parent -isnot [System.Management.Automation.Language.AssignmentStatementAst]) {
			Add-VariablePath $variable.VariablePath.UserPath
		}
	}
}

function Add-TaskVariable($Jobs) {
	foreach($job in $Jobs) {
		$task = $all[$job]
		$info = Get-TaskComment $task

		foreach($name in $info.Environment) {
			$MapEnvironment[$name] = 1
		}
		foreach($name in $info.Parameters) {
			if ($Parameters.ContainsKey($name)) {
				$MapParameter[$name] = 1
			}
			else {
				Write-Warning "Task '$($task.Name)': unknown parameter '$name'."
			}
		}

		if (!$NoCode) {
			foreach($job in @($Task.If; $Task.Inputs; $Task.Outputs; $task.Jobs)) {
				if ($job -is [scriptblock]) {
					Add-BlockVariable $job
				}
			}
		}
	}
}

function Format-TaskHelp($TaskHelp) {
	Write-Build White Task:
	foreach($r in $TaskHelp.Task) {
		if ($r.Synopsis) {
			Write-Build Gray ('    {0} - {1}' -f $r.Name, $r.Synopsis)
		}
		else {
			Write-Build Gray ('    {0}' -f $r.Name)
		}
	}

	Write-Build White Jobs:
	foreach($r in $TaskHelp.Jobs) {
		Write-Build Gray ('    {0} - {1}' -f $r.Name, $r.Location)
	}

	if ($TaskHelp.Parameters) {
		Write-Build White Parameters:
		foreach($param in $TaskHelp.Parameters) {
			Write-Build Gray ('    [{0}] {1}' -f $param.Type, $param.Name)
			if ($param.Description) {
				Write-Build Gray ('        {0}' -f $param.Description)
			}
		}
	}

	if ($TaskHelp.Environment) {
		Write-Build White Environment:
		Write-Build Gray ('    {0}' -f ($TaskHelp.Environment -join ', '))
	}
}

### .Task
$TaskHelp = 1 | Select-Object Task, Jobs, Synopsis, Location, Parameters, Environment
$TaskHelp.Task = @(
	foreach($job in $BuildTask) {
		$job, $null = *Job $job
		$task = $all[$job]
		if (!$task) {*Fin "Missing task '$job' in '$BuildFile'." 5}
		$r = 1 | Select-Object Name, Synopsis
		$r.Name = $task.Name
		$r.Synopsis = Get-BuildSynopsis $task $Hash
		$r
	}
)

### .Jobs
Add-TaskJob $BuildTask
$TaskHelp.Jobs = @(
	foreach($name in $BuildJobs) {
		$task = $all[$name]
		$r = 1 | Select-Object Name, Location
		$r.Name = $task.Name
		$r.Location = '{0}:{1}' -f $task.InvocationInfo.ScriptName, $task.InvocationInfo.ScriptLineNumber
		$r
	}
)

### .Parameters and .Environment
Add-TaskVariable $BuildJobs
$TaskHelp.Environment = @($MapEnvironment.get_Keys() | Sort-Object)

# make parameter objects with help
$TaskHelp.Parameters = @()
foreach($name in $MapParameter.get_Keys()) {
	$param = $Parameters[$name]
	$r = 1 | Select-Object Name, Type, Description
	$r.Name = $name

	$type = $param.ParameterType.Name
	if ($type -eq 'SwitchParameter') {
		$r.Type = 'switch'
	}
	else {
		$r.Type = $type
	}

	$r.Description = foreach($_ in $Help) {
		if ($_.name -eq $name -and $_.PSObject.Properties['description']) {
			($_.description | Out-String).Trim()
			break
		}
	}
	$TaskHelp.Parameters += $r
}
$TaskHelp.Parameters = @($TaskHelp.Parameters | Sort-Object {$_.Type -eq 'switch'}, Name)

# finish
& $Format $TaskHelp
tools\New-VSCodeTask.ps1
<#PSScriptInfo
.VERSION 1.3.2
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.TAGS Invoke, Task, Invoke-Build, VSCode
.GUID b8b2b532-28f6-443a-b0b1-079a66dd4ce3
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>

<#
.Synopsis
	Makes VSCode tasks from Invoke-Build tasks and tasks-merge.json

.Description
	Change to your VSCode workspace directory before invoking this command.

	The script creates ".vscode/tasks.json" based on the Invoke-Build tasks and
	the optional "tasks-merge.json" tasks. Do not edit "tasks.json" directly.
	When you add, remove, rename tasks, change script locations, or modify
	"tasks-merge.json" then regenerate.

	The default task becomes the so called VSCode build task (Ctrl+Shift+B).
	The default task is "." if it exists, otherwise it is the first task.

	To invoke another task from VSCode, hit F1 or Ctrl+Shift+P, type "Run
	Task", type a task name or select it from the task list. Even better,
	set your keyboard shortcut for "workbench.action.tasks.runTask".

	Only tasks with certain names are included. They contain alphanumeric
	characters, "_", ".", and "-", with the first character other than "-".

.Parameter BuildFile
		Specifies the build script path, absolute or relative. By default it is
		the default script in the current location, i.e. in the workspace root.

.Parameter InvokeBuild
		Specifies Invoke-Build.ps1 path, absolute or relative. If it is omitted
		then any found in workspace is used. Otherwise, "Invoke-Build" is used.

.Parameter Shell
		Specifies the name or path of the powershell or pwsh executable.
		The default is "powershell.exe".

.Parameter Merge
		Specifies the tasks to be merged with the generated Invoke-Build tasks.
		The default is ".vscode/tasks-merge.json", it is merged automatically.
		The schema is the same as "tasks.json". The property "tasks" must be
		defined as the array of task objects. Other properties are not used.
		Lines starting with "//" are treated as comments and ignored.
		The tasks are added or merged with existing by properties.

.Parameter WhereTask
		Tells to filter tasks and specifies the filter script block. The script
		checks the task $_ and gets $true/$false in order to include/exclude.

.Example
	> New-VSCodeTask

	This command binds to the default build script in the workspace root and
	Invoke-Build.ps1 either in the workspace root or subdirectory or in the
	path or the module command.

.Example
	> New-VSCodeTask ./Scripts/Build.ps1 ./packages/InvokeBuild/Invoke-Build.ps1

	This command uses relative build and engine script paths. The second may be
	omitted, Invoke-Build.ps1 will be discovered. But it is needed if there may
	be several Invoke-Build.ps1 in the workspace.

.Example
	> New-VSCodeTask -WhereTask {$_.Name -notlike "_*" -and $_.Jobs.Count -ge 2}

	This command filters tasks and tells to exclude tasks like "_*" and include
	tasks with two or more jobs.
#>

[CmdletBinding()]
param(
	[string]$BuildFile,
	[string]$InvokeBuild,
	[string]$Shell = 'powershell.exe',
	[string]$Merge = '.vscode/tasks-merge.json',
	[scriptblock]$WhereTask
)

trap {Write-Error -ErrorRecord $_}
$ErrorActionPreference = 1

# resolve Invoke-Build.ps1
if (!$InvokeBuild) {
	$_ = @(Get-ChildItem . -Name -Recurse -Filter Invoke-Build.ps1)
	if ($_) {
		$InvokeBuild = './{0}' -f $_[0]
	}
	else {
		$InvokeBuild = 'Invoke-Build'
	}
}

# get all tasks and the default task
$all = & $InvokeBuild ?? -File $BuildFile
$dot = if ($all['.']) {'.'} else {$all.Item(0).Name}

# get inputs tasks, optionally filtered
if ($WhereTask) {
	$tasks1 = @($all.get_Values() | Where-Object $WhereTask)
}
else {
	$tasks1 = $all.get_Values()
}

### result task data
$tasks2 = [System.Collections.Generic.List[object]]@()
$data = [ordered]@{
	version = '2.0.0'
	windows = [ordered]@{
		options = [ordered]@{
			shell = [ordered]@{
				executable = $Shell
				args = '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command'
			}
		}
	}
	linux = [ordered]@{
		options = [ordered]@{
			shell = [ordered]@{
				executable = '/usr/bin/pwsh'
				args = '-NoProfile', '-Command'
			}
		}
	}
	osx = [ordered]@{
		options = [ordered]@{
			shell = [ordered]@{
				executable = '/usr/local/bin/pwsh'
				args = '-NoProfile', '-Command'
			}
		}
	}
	tasks = $tasks2
}

### add main tasks
$argIB = if ($InvokeBuild -eq 'Invoke-Build') {'Invoke-Build'} else {"& '{0}'" -f $InvokeBuild.Replace('\', '/').Replace("'", "''")}
$argFile = if ($BuildFile) {" -File '{0}'" -f $BuildFile.Replace('\', '/').Replace("'", "''")} else {''}
foreach($task1 in $tasks1) {
	$name = $task1.Name
	if ($name -match '[^\w\.\-]|^-') {
		continue
	}
	$task2 = [ordered]@{
		label = $name
		type = 'shell'
		command = '{0} -Task {1}{2}' -f $argIB, $name, $argFile
		problemMatcher = '$msCompile'
		presentation = [ordered]@{
			echo = $false
			showReuseMessage = $false
		}
	}
	if ($name -eq $dot) {
		$task2.group = [ordered]@{
			kind = 'build'
			isDefault = $true
		}
	}
	$tasks2.Add($task2)
}

### add help task
$task2 = [ordered]@{
	label = '?'
	type = 'shell'
	command = '{0} -Task ?{1}' -f $argIB, $argFile
	problemMatcher = '$msCompile'
	presentation = [ordered]@{
		echo = $false
		showReuseMessage = $false
	}
}
$tasks2.Add($task2)

### merge tasks
if ($Merge -and (Test-Path -LiteralPath $Merge)) {&{
	# read and replace line comments with empty lines, to preserve line numbers
	$lines = Get-Content -LiteralPath $Merge | .{process{if ($_ -match '^\s*//') {''} else {$_}}}
	Set-StrictMode -Off
	try {
		$json = $lines | ConvertFrom-Json
		if (!($mergeTasks = $json.tasks)) {
			throw "Missing required property 'tasks'."
		}
		foreach($task2 in $mergeTasks) {
			# get task label
			if (!($label = $task2.label)) {
				throw "Tasks must define 'label'."
			}

			# find existing task
			$task1 = $null
			foreach($_ in $tasks2) {
				if ($label -eq $_.label) {
					$task1 = $_
					break
				}
			}

			# merge existing task or add new
			if ($task1) {
				foreach($_ in $task2.PSObject.Properties) {
					$task1[$_.Name] = $_.Value
				}
			}
			else {
				$tasks2.Add($task2)
			}
		}
	}
	catch {
		throw "Cannot merge '$Merge': $_"
	}
}}

### save tasks.json
$Header1 = '// Do not edit! This file is generated by New-VSCodeTask.ps1'
$Header2 = '// Modify the build script or tasks-merge.json and recreate.'
if (!(Test-Path .vscode)) {
	$null = mkdir .vscode
}
elseif (Test-Path .vscode/tasks.json) {
	$line1, $null = Get-Content .vscode/tasks.json
	if ($line1 -ne $Header1) {
		Remove-Item .vscode/tasks.json -Confirm
		if (Test-Path .vscode/tasks.json) {
			return
		}
	}
}
$(
	$Header1
	$Header2
	ConvertTo-Json $data -Depth 99
) |
Set-Content .vscode/tasks.json -Encoding UTF8
tools\Show-BuildDgml.ps1
<#
.Synopsis
	Shows Invoke-Build task graph using DGML.
	Copyright (c) Roman Kuzmin

.Description
	Requires:
	- Visual Studio: Individual components \ Code tools \ DGML editor.
	- Invoke-Build is in the path or available as the module command.

	The script calls Invoke-Build in order to get the tasks, builds the DGML
	and invokes the associated application (Visual Studio) in order to show it.

	Tasks with code are shown as boxes, tasks without code are shown as ovals.
	Safe references are shown with dotted edges, regular calls are shown with
	solid edges. Job numbers are not shown by default.

	EXAMPLES

	# Make and show DGML for the default build script
	Show-BuildDgml

	# Make Build.dgml with job numbers
	Show-BuildDgml -Number -NoShow -Output Build.dgml

.Parameter File
		See: help Invoke-Build -Parameter File

.Parameter Output
		The output file and the format specified by its extension.
		The default is "$env:TEMP\name-xxxxxxxx.dgml".

.Parameter Parameters
		Build script parameters needed in special cases when they alter tasks.

.Parameter NoShow
		Tells to create the output file without showing it.
		In this case Output is normally specified by a caller.

.Parameter Number
		Tells to show job numbers on edges connecting tasks.

.Link
	https://github.com/nightroman/Invoke-Build
#>

param(
	[Parameter(Position=0)]
	[string]$File
	,
	[Parameter(Position=1)]
	[string]$Output
	,
	[hashtable]$Parameters
	,
	[switch]$NoShow
	,
	[switch]$Number
)

$ErrorActionPreference = 1

### resolve output
if ($Output) {
	$Output = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($Output)
}
else {
	$path = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($(if ($File) {$File} else {''}))
	$name = [System.IO.Path]::GetFileNameWithoutExtension($path)
	$hash = [System.IO.Path]::GetFileName([System.IO.Path]::GetDirectoryName($path))
	$Output = [System.IO.Path]::GetTempPath() + "$name-$hash.dgml"
}

### get tasks
if (!$Parameters) {$Parameters = @{}}
$all = Invoke-Build ?? $File @Parameters

### for synopses
$docs = @{}
. Invoke-Build

### make DGML
$xml = [xml]'<?xml version="1.0" encoding="utf-8"?><DirectedGraph/>'
$doc = $xml.DocumentElement
$nodes = $doc.AppendChild($xml.CreateElement('Nodes'))
$links = $doc.AppendChild($xml.CreateElement('Links'))
$styles = $doc.AppendChild($xml.CreateElement('Styles'))
$styles.InnerXml = @'
<Style TargetType="Node">
  <Condition Expression="HasCategory('Calls')" />
  <Setter Property="NodeRadius" Value="15" />
</Style>
<Style TargetType="Node">
  <Condition Expression="HasCategory('Script')" />
  <Setter Property="NodeRadius" Value="2" />
</Style>
'@
foreach($it in $all.get_Values()) {
	$name = $it.Name
	$node = $nodes.AppendChild($xml.CreateElement('Node'))
	$node.SetAttribute('Id', $name)

	if ($synopsis = Get-BuildSynopsis $it $docs) {
		$node.SetAttribute('Synopsis', $synopsis)
	}

	$jobNumber = 0
	$hasScript = $false
	foreach($job in $it.Jobs) {
		++$jobNumber
		if ($job -is [string]) {
			$job, $safe = if ($job[0] -eq '?') {$job.Substring(1), 1} else {$job}
			$job = $all[$job].Name
			$link = $links.AppendChild($xml.CreateElement('Link'))
			$link.SetAttribute('Source', $name)
			$link.SetAttribute('Target', $job)
			if ($Number) {
				$link.SetAttribute('Label', $jobNumber)
			}
			if ($safe) {
				$link.SetAttribute('StrokeDashArray', '2 2')
			}
		}
		else {
			$hasScript = $true
		}
	}

	if ($hasScript) {
		$node.SetAttribute('Category', 'Script')
	}
	else {
		$node.SetAttribute('Category', 'Calls')
	}
}

### save DGML
$doc.SetAttribute('xmlns', 'http://schemas.microsoft.com/vs/2009/dgml')
$xml.Save($Output)

### show file
if (!$NoShow) {
	Invoke-Item -LiteralPath $Output
}
tools\Show-BuildTree.ps1
<#
.Synopsis
	Shows Invoke-Build task trees with brief information.
	Copyright (c) Roman Kuzmin

.Description
	This script analyses task references and shows parent tasks and child trees
	for the specified tasks. Tasks are not invoked.

.Parameter Task
		Task names.
		If it is "*" then all root tasks are used.
		If it is omitted or "." then the default task is used.

.Parameter File
		The build script.
		If it is omitted then the default script is used.

.Parameter Parameters
		Build script parameters needed in special cases when they alter tasks.

.Parameter Upstream
		Tells to show upstream tasks for each task.

.Outputs
	Specified task trees.

.Link
	https://github.com/nightroman/Invoke-Build
#>

param(
	[Parameter(Position=0)]
	[string[]]$Task
	,
	[Parameter(Position=1)]
	[string]$File
	,
	[Parameter(Position=2)]
	[hashtable]$Parameters
	,
	[switch]$Upstream
)

$ErrorActionPreference = 1

$private:_Task = $Task
$private:_File = $File
$private:_Parameters = if ($Parameters) {$Parameters} else {@{}}
$private:_Upstream = $Upstream
Remove-Variable Task, File, Parameters, Upstream

# Shows the task tree.
function ShowTaskTree($Task, $Docs, $Step = 0) {
	if ($Step -eq 0) {''}
	$tab = '    ' * $Step
	++$Step

	# synopsis
	$synopsis = Get-BuildSynopsis $Task $docs

	# name
	$info = $tab + $Task.Name

	# upstream
	if ($references.get_Count()) {
		$reference = $references[$Task]
		if ($reference.get_Count()) {
			$info += ' (' + (($reference.get_Keys() | Sort-Object) -join ', ') + ')'
		}
	}

	# synopsis, output
	if ($synopsis) {"$info # $synopsis"} else {$info}

	# task jobs
	foreach($_ in $Task.Jobs) {
		if ($_ -is [string]) {
			$r, $s = *Job $_
			ShowTaskTree $tasks[$r] $Docs $Step
		}
		else {
			$tab + '    {}'
		}
	}
}

try {
	. Invoke-Build

	# get tasks
	$tasks = Invoke-Build ?? $_File @_Parameters

	# references
	$references = @{}
	if ($_Upstream) {
		foreach($it in $tasks.get_Values()) {
			$references[$it] = @{}
		}
		foreach($it in $tasks.get_Values()) {foreach($job in $it.Jobs) {if ($job -is [string]) {
			$references[$tasks[$job]][$it.Name] = 0
		}}}
	}

	# resolve task
	if ($_Task -eq '*') {
		$_Task = :task foreach($_ in $tasks.get_Keys()) {
			foreach($task in $tasks.get_Values()) {
				if ($task.Jobs -contains $_ -or $task.Jobs -contains "?$_") {
					continue task
				}
			}
			$_
		}
	}
	elseif (!$_Task -or '.' -eq $_Task) {
		$_Task = if ($tasks['.']) {'.'} else {$tasks.Item(0).Name}
	}

	# test tasks
	foreach($name in $_Task) {
		if (!$tasks[$name]) {throw "Missing task '$name'."}
	}

	# show trees
	$docs = @{}
	foreach($name in $_Task) {
		ShowTaskTree $tasks[$name] $docs
	}
}
catch {
	if ($_.InvocationInfo.ScriptName -ne $MyInvocation.MyCommand.Path) {throw}
	$PSCmdlet.ThrowTerminatingError($_)
}

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status
Invoke-Build 5.12.0 87 Thursday, November 21, 2024 Approved
Invoke-Build 5.11.3 506 Saturday, July 6, 2024 Approved
Invoke-Build 5.11.2 118 Wednesday, June 12, 2024 Approved
Invoke-Build 5.11.1 213 Sunday, April 14, 2024 Approved
Invoke-Build 5.11.0 209 Saturday, March 9, 2024 Approved
Invoke-Build 5.10.6 51 Tuesday, March 5, 2024 Approved
Invoke-Build 5.10.5 331 Saturday, December 16, 2023 Approved
Invoke-Build 5.10.4 832 Tuesday, May 16, 2023 Approved
Invoke-Build 5.10.3 351 Friday, March 10, 2023 Approved
Invoke-Build 5.10.2 130 Thursday, February 9, 2023 Approved
Invoke-Build 5.10.1 430 Tuesday, October 25, 2022 Approved
Invoke-Build 5.10.0 130 Saturday, October 22, 2022 Approved
Invoke-Build 5.9.12 812 Saturday, September 17, 2022 Approved
Invoke-Build 5.9.11 597 Sunday, August 21, 2022 Approved
Invoke-Build 5.9.10 1695 Tuesday, April 12, 2022 Approved
Invoke-Build 5.9.9.0 607 Thursday, March 10, 2022 Approved
Invoke-Build 5.9.8 139 Monday, March 7, 2022 Approved
Invoke-Build 5.9.7 405 Thursday, February 10, 2022 Approved
Invoke-Build 5.9.6 166 Saturday, February 5, 2022 Approved
Invoke-Build 5.9.5 106 Friday, February 4, 2022 Approved
Invoke-Build 5.9.4 140 Wednesday, February 2, 2022 Approved
Invoke-Build 5.9.3 136 Saturday, January 29, 2022 Approved
Invoke-Build 5.9.2 102 Friday, January 28, 2022 Approved
Invoke-Build 5.9.1 110 Thursday, January 27, 2022 Approved
Invoke-Build 5.9.0 249 Monday, January 17, 2022 Approved
Invoke-Build 5.8.8 280 Sunday, January 2, 2022 Approved
Invoke-Build 5.8.7 243 Monday, December 13, 2021 Approved
Invoke-Build 5.8.6 312 Thursday, November 25, 2021 Approved
Invoke-Build 5.8.5 361 Wednesday, November 10, 2021 Approved
Invoke-Build 5.8.4 1090 Sunday, August 15, 2021 Approved
Invoke-Build 5.8.3 95 Saturday, August 14, 2021 Approved
Invoke-Build 5.8.1 196 Sunday, July 18, 2021 Approved
Invoke-Build 5.8.0 1001 Friday, April 16, 2021 Approved
Invoke-Build 5.7.3 301 Saturday, March 27, 2021 Approved
Invoke-Build 5.7.2 500 Sunday, March 7, 2021 Approved
Invoke-Build 5.7.1 223 Saturday, February 27, 2021 Approved
Invoke-Build 5.7.0 256 Saturday, February 20, 2021 Approved
Invoke-Build 5.6.5 927 Monday, January 11, 2021 Approved
Invoke-Build 5.6.4 252 Thursday, December 17, 2020 Approved
Invoke-Build 5.6.3 518 Monday, November 23, 2020 Approved
Invoke-Build 5.6.2 614 Friday, September 11, 2020 Approved
Invoke-Build 5.6.1 242 Friday, August 7, 2020 Approved
Invoke-Build 5.6.0 717 Thursday, May 21, 2020 Approved
Invoke-Build 5.5.11 287 Tuesday, April 28, 2020 Approved
Invoke-Build 5.5.9 264 Wednesday, April 8, 2020 Approved
Invoke-Build 5.5.8 371 Tuesday, March 24, 2020 Approved
Invoke-Build 5.5.7 342 Friday, February 7, 2020 Approved
Invoke-Build 5.5.6 227 Monday, December 16, 2019 Approved
Invoke-Build 5.5.5 244 Thursday, October 17, 2019 Approved
Invoke-Build 5.5.3 270 Friday, August 30, 2019 Approved
Invoke-Build 5.5.2 255 Wednesday, June 12, 2019 Approved
Invoke-Build 5.5.1 264 Wednesday, April 10, 2019 Approved
Invoke-Build 5.5.0 236 Thursday, April 4, 2019 Approved
Invoke-Build 5.4.6 197 Thursday, March 28, 2019 Approved
Invoke-Build 5.4.5 262 Wednesday, March 6, 2019 Approved
Invoke-Build 5.4.4 241 Monday, February 25, 2019 Approved
Invoke-Build 5.4.3 253 Friday, February 15, 2019 Approved
Invoke-Build 5.4.2 662 Saturday, December 8, 2018 Approved
Invoke-Build 5.4.1 699 Thursday, April 12, 2018 Approved
Invoke-Build 5.4.0 349 Tuesday, April 3, 2018 Approved
Invoke-Build 5.3.0 345 Saturday, March 24, 2018 Approved
Invoke-Build 5.2.1 339 Tuesday, March 20, 2018 Approved
Invoke-Build 5.2.0 356 Tuesday, February 27, 2018 Approved
Invoke-Build 5.1.1 337 Thursday, February 15, 2018 Approved
Invoke-Build 5.1.0 329 Thursday, February 8, 2018 Approved
Invoke-Build 5.0.1 374 Tuesday, January 16, 2018 Approved
Invoke-Build 5.0.0 365 Tuesday, January 2, 2018 Approved
Invoke-Build 4.2.0 348 Wednesday, December 20, 2017 Approved
Invoke-Build 4.1.2 403 Thursday, December 7, 2017 Approved
Invoke-Build 4.1.1 354 Monday, December 4, 2017 Approved
Invoke-Build 4.1.0 335 Tuesday, November 28, 2017 Approved
Invoke-Build 4.0.2 381 Sunday, November 26, 2017 Approved
Invoke-Build 4.0.1 341 Thursday, November 23, 2017 Approved
Invoke-Build 4.0.0 380 Wednesday, November 15, 2017 Approved
Invoke-Build 3.7.2 385 Tuesday, November 7, 2017 Approved
Invoke-Build 3.7.1 409 Sunday, October 29, 2017 Approved
Invoke-Build 3.6.5.20170830 475 Wednesday, August 30, 2017 Approved
Invoke-Build 3.6.4 446 Saturday, July 29, 2017 Approved
Invoke-Build 3.6.3 349 Thursday, July 27, 2017 Approved
Invoke-Build 3.6.2 375 Friday, July 21, 2017 Approved
Invoke-Build 3.6.1 394 Saturday, July 15, 2017 Approved
Invoke-Build 3.6.0 382 Saturday, July 8, 2017 Approved
Invoke-Build 3.5.3 405 Friday, June 30, 2017 Approved
Invoke-Build 3.5.2 388 Tuesday, June 27, 2017 Approved
Invoke-Build 3.5.1 422 Thursday, June 22, 2017 Approved
Invoke-Build 3.5.0 356 Saturday, June 17, 2017 Approved
Invoke-Build 3.4.0 385 Thursday, June 8, 2017 Approved
Invoke-Build 3.3.11 385 Friday, June 2, 2017 Approved
Invoke-Build 3.3.10 401 Friday, May 26, 2017 Approved
Invoke-Build 3.3.9 360 Saturday, May 20, 2017 Approved
Invoke-Build 3.3.8 461 Friday, May 12, 2017 Approved
Invoke-Build 3.3.7 367 Tuesday, May 9, 2017 Approved
Invoke-Build 3.3.6 356 Sunday, April 30, 2017 Approved
Invoke-Build 3.3.5 401 Monday, April 24, 2017 Approved
Invoke-Build 3.3.4 397 Sunday, April 16, 2017 Approved

This package has no dependencies.

Discussion for the Invoke-Build Package

Ground Rules:

  • This discussion is only about Invoke-Build and the Invoke-Build package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or Invoke-Build, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus