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,064

Downloads of v 3.6.5.20170830:

470

Last Update:

30 Aug 2017

Package Maintainer(s):

Software Author(s):

  • Roman Kuzmin

Tags:

build powershell module cross-platform foss

Invoke-Build

This is not the latest version of Invoke-Build available.

  • 1
  • 2
  • 3

3.6.5.20170830 | Updated: 30 Aug 2017

Downloads:

35,064

Downloads of v 3.6.5.20170830:

470

Maintainer(s):

Software Author(s):

  • Roman Kuzmin

Invoke-Build 3.6.5.20170830

This is not the latest version of Invoke-Build available.

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'" --version="'3.6.5.20170830'" [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'" --version="'3.6.5.20170830'" 
$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: '3.6.5.20170830'
    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  '3.6.5.20170830'
end

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


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

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


package { 'invoke-build':
  ensure   => '3.6.5.20170830',
  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.

WARNING

There are versions of this package awaiting moderation . See the Version History section below.

Package Approved

This package was approved as a trusted package on 30 Aug 2017.

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.
  • 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.2
.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.

	* TabExpansionPlusPlus https://github.com/lzybkr/TabExpansionPlusPlus
	Put Invoke-Build.ArgumentCompleters.ps1 to the TabExpansionPlusPlus module
	directory in order to be loaded automatically. Or invoke it after importing
	the module, 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'])).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.2
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) 2011-2016 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 = 'Stop'

$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).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.5
.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
)

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

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

$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).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
}
tools\InvokeBuild\3.6.5\about_InvokeBuild.help.txt
TOPIC
    about_InvokeBuild

SHORT DESCRIPTION
    Build and test automation in PowerShell

LONG DESCRIPTION
    The module provides two commands:

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

        Invoke-Builds
            The alias of Invoke-Builds.ps1
            It invokes parallel builds using the engine.

    Import the module:

        Import-Module InvokeBuild

    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
        ...
tools\InvokeBuild\3.6.5\ib.cmd

:: ib.cmd - Invoke-Build helper for cmd.exe
:: It must be in the same directory as Invoke-Build.ps1

@echo off

if "%1"=="?" goto list
if "%1"=="/?" goto help

powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0Invoke-Build.ps1' %*"
exit /B %errorlevel%

:list
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0Invoke-Build.ps1' %* | Format-Table -AutoSize"
exit /B 0

:help
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "help -Full '%~dp0Invoke-Build.ps1'"
exit /B 0
tools\InvokeBuild\3.6.5\Invoke-Build-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 specified and referenced tasks defined in a PowerShell
script. The process is called build and the script is called build script.

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

To get help for commands dot-source Invoke-Build:

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

USING BUILD SCRIPT PARAMETERS

Build scripts define parameters using param(). They are used in tasks as
$ParameterName for reading and as $script:ParameterName for writing.

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

Script parameters are specified for Invoke-Build as if they are its own.
Known issue #4. Script switches should be specified after Task and File.

Build script parameters are automatically exported and imported by the
engine on persistent builds, see Checkpoint.

RESERVED FUNCTION AND VARIABLE NAMES

Function and variable names starting with &apos;*&apos; are reserved for the engine.
Scripts should not use functions and variables with such names.

EXPOSED FUNCTIONS AND ALIASES

Scripts should use available aliases instead of function names.

    Add-BuildTask (task)
    Assert-Build (assert)
    Assert-BuildEquals (equals)
    Get-BuildError (error)
    Get-BuildProperty (property)
    Get-BuildSynopsis
    Get-BuildVersion
    Invoke-BuildExec (exec)
    New-BuildJob (job)
    Resolve-MSBuild
    Test-BuildAsset (requires)
    Use-BuildAlias (use)
    Write-Build
    Write-Warning [1]
    Get-BuildFile [2]

[1] Write-Warning is redefined internally in order to count warnings in
tasks, build, and other scripts. But warnings in modules are not counted.

[2] Exists only as a pattern for wrappers.

SPECIAL ALIASES

    Invoke-Build
    Invoke-Builds

These aliases are for the scripts Invoke-Build.ps1 and Invoke-Builds.ps1.
Use them for calling nested builds, i.e. omit script extensions and paths.
With this rule Invoke-Build tools can be kept together with build scripts.

EXPOSED VARIABLES

Exposed variables designed for build scripts and tasks:

    $WhatIf    - WhatIf mode, Invoke-Build parameter
    $BuildRoot - build script location
    $BuildFile - build script path
    $BuildTask - initial tasks
    $Task      - current task

$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.

    $Task properties available for reading:

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

    In Exit-BuildTask
    - Error - error which stopped the task
    - Elapsed - [TimeSpan], task duration

The variable $_ may be exposed. In special cases it is used as an input.
In other cases build scripts should not assume anything about its value.

BUILD BLOCKS

Scripts may define the following build blocks. They are invoked:

    Enter-Build {} - before all tasks
    Exit-Build {} - after all tasks

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

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

    Export-Build {} - on saving persistent build checkpoints
    Import-Build {param($data)} - once on resuming persistent builds

    Set-BuildHeader {param($path)} - custom task header writer

Nested builds do not inherit parent blocks.
If Enter-X is called then Exit-X is called.
Blocks are not called on WhatIf, except Set-BuildHeader.

Enter-Build and Exit-Build are invoked in the script scope. Enter-Build is
a good place for heavy initialization, it does not have to care of WhatIf.
Also, unlike the top level script code, Enter-Build can output text.

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

Export-Build and Import-Build are used with persistent builds. Export-Build
outputs data to be exported to clixml. Import-Build is called with a single
argument containing the original data imported from clixml. It is called in
the script scope and normally restores script scope variables. Note that
this is not needed for script parameters, the engine takes care of them.
Variables may be declared as parameters just in order to be persistent.

DOT-SOURCING Invoke-Build

Build-like environment can be imported to normal scripts:

    . Invoke-Build [&lt;root&gt;]

When this command is invoked from a script it

- sets $ErrorActionPreference to Stop
- sets $BuildFile to the invoked script path
- sets $BuildRoot to the script directory or &lt;root&gt;
- sets the current PowerShell location to $BuildRoot
- imports utility commands
    - assert
    - equals
    - exec
    - property
    - requires
    - use
    - Write-Build

Some other build commands are also imported. They are available for getting
help and not designed for use in normal scripts.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-Build.ps1</maml:name>
<command:parameter required="false" position="1" >
<maml:name>Task</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>File</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Checkpoint</maml:name>
<command:parameterValue required="true">String</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>Resume</maml:name>
</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="1" >
<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 tasks.

SPECIAL TASKS

? - Tells to list the tasks with brief information without invoking. It
also checks tasks and throws errors on missing or cyclic references.
Task synopsis is defined in preceding comments as # Synopsis: ...

?? - Tells to collect and get all tasks as an ordered dictionary. It
can be used by external tools for analysis, TabExpansion, and 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. This is useful when all tasks are tests
or steps in a sequence that can be stopped and resumed, see Checkpoint.

** - Invokes * for all files *.test.ps1 found recursively in the
current directory or a directory specified by the parameter File.
Other parameters except Result and Safe are ignored.

Tasks ? and ?? can be combined with **
?, ** - To show all test tasks without invoking.
??, ** - To get task dictionaries for all test files.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>File</maml:name>
<maml:description>
<maml:para>A build script which defines tasks by the alias &apos;task&apos; (Add-BuildTask).

If it is not specified then Invoke-Build looks for *.build.ps1 files in
the current location. A single file is used as the script. If there are
more files then .build.ps1 is used if it exists, otherwise build fails.

If the build file is not found then a script defined by the environment
variable InvokeBuildGetFile is called with the path as an argument. For
this location it may return the full path of a special build script.

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

INLINE SCRIPT

`File` is a script block as a build script. It is used in order to
assemble a build on the fly without creating an extra build script.
Dynamic parameters and persistent builds are not used in this case.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Checkpoint</maml:name>
<maml:description>
<maml:para>Specifies the checkpoint file and makes the build persistent. It is
possible to resume an interrupted build starting at the interrupted
task. The checkpoint file is written before processing of each task
and deleted if the build succeeds.

In order to resume an interrupted persistent build specify the same
checkpoint file and the switch Resume. Task, File, and build script
parameters should not be used, they are restored from the file.

Persistent builds must be designed properly. Data shared by tasks
may have to be persisted with Export-Build and Import-Build.

Note that this is not needed for script parameters, the engine takes
care of them. Some variables may be declared as parameters simply in
order to be persistent and custom export and import may be avoided.

Notes
- Think carefully of what the persistent build state is.
- Some data are not suitable for persistence in clixml files.
- Changes in stopped build scripts may cause incorrect resuming.
- Checkpoint files must not be used with different engine versions.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<maml:description>
<maml:para>Tells to output build information using a variable. It is either a name
of variable to be created or any object with the property Value to be
assigned (e.g. [ref] or [hashtable]).

Result object 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 and .ScriptLineNumber)

Errors is a list of objects:

    Error - original error record
    File - current $BuildFile
    Task - current $Task or null for non-task errors

Warnings is a list of objects:

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

These data should be used for reading only.
Other result and task data should not be used.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Resume</maml:name>
<maml:description>
<maml:para>Tells to resume an interrupted persistent build from a checkpoint file
specified by Checkpoint. Task, File, and build script parameters should
not be used, they are restored from the file.</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 preprocessed tasks and their scripts instead of invoking
them. If a script does anything but adding and configuring tasks then
it should check for $WhatIf and skip some significant 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 process log which includes task starts, ends with durations,
warnings, errors, and output of tasks and commands that they invoke.

Output is expected from tasks and blocks. But script scope code should
not output anything. Unexpected 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># Invoke the default task (&apos;.&apos; or the first added) in the default script
# (a single file like *.build.ps1 or .build.ps1 if there are two or more)

Invoke-Build</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># Invoke a persistent sequence of steps defined as tasks
Invoke-Build * Steps.build.ps1 -Checkpoint temp.clixml

# Resume the above steps at the stopped one
Invoke-Build -Checkpoint temp.clixml -Resume</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 7 --------------------------</maml:title>
<dev:code># Using the build results, e.g. for performance analysis

# Invoke the build and keep results in the variable Result
Invoke-Build -Result Result

# Show invoked tasks ordered by Elapsed with ScriptName included
$Result.Tasks |
Sort-Object Elapsed |
Format-Table -AutoSize Elapsed, @{
	Name = &apos;Task&apos;
	Expression = {$_.Name + &apos; @ &apos; + $_.InvocationInfo.ScriptName}
}</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 8 --------------------------</maml:title>
<dev:code># Using the build results, e.g. for tasks summary

try {
	# Invoke the build and keep results in the variable Result
	Invoke-Build -Result Result
}
finally {
	# Show task summary information after the build
	$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>Add-BuildTask (task)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert-Build (assert)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert-BuildEquals (equals)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-BuildError (error)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-BuildProperty (property)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-BuildExec (exec)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-BuildJob (job)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Resolve-MSBuild</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Test-BuildAsset (requires)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Use-BuildAlias (use)</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>Defines a build task and adds it to the internal task list.</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;. This is the main feature of build scripts. At
least one task must be added. Normally it is used in the build script scope
but it can be called anywhere, e.g. imported, created dynamically, and etc.

In fact, this function is literally all that build scripts really need.
Other build functions are just helpers, scripts do not have to use them.

Task help-comments are special comments preceding task definitions

    # Synopsis: ...
    task ...

Synopsis lines are used in task information returned by the command

    Invoke-Build ?</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Add-BuildTask</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<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">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Before</maml:name>
<command:parameterValue required="true">Object[]</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="1" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>The task name. Wildcard characters are deprecated. 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="2" >
<maml:name>Jobs</maml:name>
<maml:description>
<maml:para>Specifies the task jobs. Jobs are other task references and own
actions. Any number of jobs is allowed. Jobs are invoked in the
specified order.

Valid job types are:

    [string] - simple reference, an existing task name
    [object] - advanced reference created by &apos;job&apos; (New-BuildJob)
    [scriptblock] - action, a script block invoked for this task</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 the specified task job lists.

Altered tasks are defined as by their names or by the command &apos;job&apos;.
In the latter case options are applied to the added task reference.

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.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Before</maml:name>
<maml:description>
<maml:para>Tells to add this task to job lists of the specified tasks. It is
inserted before the first script job, if any, or added to the end.
Note that Before tasks are added before After tasks.

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 the 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 invoked when the task is done.
It is mostly designed for wrapper functions creating special tasks.</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 will only
be evaluated when the task is loaded into the build engine. A use case
for this notation might be evaluating parameters that are passed into
the build.

    Example:
        task SomeTask -If ($SomeCondition) {...}

Using script block notation (curly braces) the condition will be
evaluated dynamically 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.

    Example:
        task SomeTask -If {$SomeCondition} {...}

On WhatIf:
- Boolean conditions are evaluated and treated accordingly.
- Script block conditions are treated as true without invocation.</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 more 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 together 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 task help synopsis.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>New-BuildJob</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-BuildError</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>New-BuildJob</command:name>
<maml:description>
<maml:para>Creates a new task reference with options.</maml:para>
</maml:description>
<command:verb>New</command:verb>
<command:noun>BuildJob</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;job&apos;. It is called on job list creation for a task.
It creates a reference to another task with options. The only used option
is the switch Safe.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>New-BuildJob</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Safe</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="1" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>The referenced task name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Safe</maml:name>
<maml:description>
<maml:para>Tells to create a safe task job. If the referenced task fails the build
continues if this task is safe everywhere in the current build. Other
tasks use &apos;error&apos; (Get-BuildError) in order to check for errors.</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>A new job used as an argument on task creation.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Get-BuildError</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-BuildError</command:name>
<maml:description>
<maml:para>Gets an error of the specified task if the task has failed.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildError</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias &apos;error&apos;. It is used when some tasks are referenced
safe (job Task -Safe) in order to get and analyse their potential errors.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildError</maml:name>
<command:parameter required="true" position="1" >
<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="1" >
<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>The error object or null if the task has no errors.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Add-BuildTask</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-BuildJob</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>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 a specified message.

NOTE: Consider to use &apos;equals X Y&apos; instead of &apos;assert (X -eq Y)&apos;. It is
easier to type, it avoids subtle PowerShell conversions, and its error
message is more informative.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Assert-Build</maml:name>
<command:parameter required="false" position="1" >
<maml:name>Condition</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<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="1" >
<maml:name>Condition</maml:name>
<maml:description>
<maml:para>The condition.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<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>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.

NOTE: Comparison of strings is case sensitive. For case insensitive
comparison use &apos;assert (X -eq Y)&apos;.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Assert-BuildEquals</maml:name>
<command:parameter required="false" position="1" >
<maml:name>A</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<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="1" >
<maml:name>A</maml:name>
<maml:description>
<maml:para>The first object.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<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>Gets the session or environment variable or default value.</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="1" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<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="1" >
<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="2" >
<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 synopsis is defined in preceding comments as # Synopsis: ...</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildSynopsis</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Task</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<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="1" >
<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="2" >
<maml:name>Hash</maml:name>
<maml:description>
<maml:para>Any hashtable to be used as a cache. Build scripts do not have to
specify it, 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>
<maml:description>
<maml:para>Task synopsis line.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Print task path and synopsis
Set-BuildHeader {
	param($Path)
	Write-Build Cyan &quot;Task $Path : $(Get-BuildSynopsis $Task)&quot;
}

# Synopsis: Show task data useful for headers
task Task1 {
	$Task.Name
	$Task.InvocationInfo.ScriptName
	$Task.InvocationInfo.ScriptLineNumber
}</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>Get-BuildVersion</command:name>
<maml:description>
<maml:para>Gets the current Invoke-Build version.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildVersion</command:noun>
</command:details>
<maml:description>
<maml:para>Gets the current Invoke-Build version.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildVersion</maml:name>
</command:syntaxItem>
</command:syntax>
<command:parameters>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Version</maml:name>
</dev:type>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>assert ((Get-BuildVersion).Major -ge 2)</dev:code>
<dev:remarks>
<maml:para>This command works like `require version`. Use it as the first command in a
build script in order to ensure that the script is being built by a proper
engine (version 2+ in this example).</maml:para>
</dev:remarks>
</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>Invoke-BuildExec</command:name>
<maml:description>
<maml:para>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.

It is often used with .NET tools, e.g. MSBuild. See Use-BuildAlias.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-BuildExec</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Command</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>ExitCode</maml:name>
<command:parameterValue required="true">Int32[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="1" >
<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 or contains an exit code of another command.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<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: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: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>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 required build
assets. It fails if something is missing or invalid. It is used either
in script code (common assets) or in tasks (individual assets).</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Test-BuildAsset</maml:name>
<command:parameter required="false" position="1" >
<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>Property</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="1" >
<maml:name>Variable</maml:name>
<maml:description>
<maml:para>Specifies session variable names and tells to fail if a variable is
missing or its value is null or an empty string.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Environment</maml:name>
<maml:description>
<maml:para>Specifies environment variable names and tells to fail if a variable is
not defined or its value is an empty string.</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 an empty string. It makes
sense to use `property` later with tested names without defaults.</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>Sets framework/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 from.

This function is often called from a build script and all tasks use script
scope aliases. But it can be called from tasks in order to use more tools
including other framework or tool directories.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Use-BuildAlias</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Path</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<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="1" >
<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.

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

If it is like VisualStudio\&lt;version&gt; then it is resolved to the
specified Visual Studio tools directory (devenv, mstest, tf, ...).
NOTE: This way is not supported starting with Visual Studio 2017,
use the special Microsoft module VSSetup from PSGallery instead.

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

Examples: *, 4.0, Framework\v4.0.30319, VisualStudio\14.0, .\Tools</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<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>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, e.g. to a console.
Unlike Write-Host it is suitable for redirected output, e.g. to a file.
If the current host does not support colors then just text is written.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Write-Build</maml:name>
<command:parameter required="false" position="1" >
<maml:name>Color</maml:name>
<command:parameterValue required="true">ConsoleColor</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Text</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="1" >
<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="false" position="2" >
<maml:name>Text</maml:name>
<maml:description>
<maml:para>Text to be printed 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>Get-BuildFile</command:name>
<maml:description>
<maml:para>Gets full path of the default build file.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildFile</command:noun>
</command:details>
<maml:description>
<maml:para>This function is not designed for build scripts and tasks.
It is used by the engine and exposed for related tools.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildFile</maml:name>
<command:parameter required="false" position="1" >
<maml:name>Path</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="1" >
<maml:name>Path</maml:name>
<maml:description>
<maml:para>A full directory path used to get the default build file.</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>Invoke-Builds.ps1</command:name>
<maml:description>
<maml:para>Invokes parallel builds by Invoke-Build.ps1</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>This script invokes build scripts simultaneously using Invoke-Build.ps1
which has to be in the same directory. Number of simultaneous builds is
limited by the number of processors by default.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-Builds.ps1</maml:name>
<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>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>Timeout</maml:name>
<command:parameterValue required="true">Int32</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="1" >
<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>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>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>Invoke-Builds @(
	@{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>
</helpItems>
tools\InvokeBuild\3.6.5\Invoke-Build.ps1

<#
Copyright 2011-2017 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 Invoke-Build-Help.xml
param(
	[Parameter(Position=0)][string[]]$Task,
	[Parameter(Position=1)]$File,
	[string]$Checkpoint,
	$Result,
	[switch]$Safe,
	[switch]$Summary,
	[switch]$Resume,
	[switch]$WhatIf
)

dynamicparam {

#.ExternalHelp Invoke-Build-Help.xml
function Get-BuildFile($Path) {
	do {
		if (($f = [System.IO.Directory]::GetFiles($Path, '*.build.ps1')).Length -eq 1) {return $f}
		if ($_ = $f -match '[\\/]\.build\.ps1$') {return $_}
		if ($f.Length -ge 2) {throw "Ambiguous default script in '$Path'."}
		if ([System.IO.File]::Exists(($_ = $env:InvokeBuildGetFile)) -and ($_ = & $_ $Path)) {return $_}
	} while($Path = Split-Path $Path)
}

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

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

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

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 = $null
	Task = $null
	File = $BuildFile = $PSBoundParameters['File']
	Checkpoint = $PSBoundParameters['Checkpoint']
	Safe = $PSBoundParameters['Safe']
	Summary = $PSBoundParameters['Summary']
	CD = *Path
	DP = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
	SP = $null
	CP = $null
	P = $(if ($_ = $PSCmdlet.SessionState.PSVariable.Get('*')) {if ($_.Description -eq 'IB') {$_.Value}})
	A = 1
	B = 0
	Q = 0
	H = @{}
	EnterBuild = $null
	ExitBuild = $null
	EnterTask = $null
	ExitTask = $null
	EnterJob = $null
	ExitJob = $null
	Export = $null
	Import = $null
	Header = {Write-Build 11 "Task $($args[0])"}
})
$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)
	return
}

if (${*}.Checkpoint) {${*}.Checkpoint = *Path ${*}.Checkpoint}
if ($PSBoundParameters['Resume']) {
	if (!${*}.Checkpoint) {throw 'Checkpoint must be defined for Resume.'}
	${*}.CP = $_ = try {Import-Clixml ${*}.Checkpoint} catch {throw 'Invalid checkpoint file?'}
	$BuildTask = $_.Task
	$BuildFile = $_.File
	${*}.SP = $_.Prm1
}
elseif ($BuildFile) {
	if (![System.IO.File]::Exists(($BuildFile = *Path $BuildFile))) {throw "Missing script '$BuildFile'."}
}
elseif (!($BuildFile = Get-BuildFile ${*}.CD)) {
	throw 'Missing default script.'
}
${*}.File = $BuildFile

if (!($_ = (Get-Command $BuildFile -ErrorAction 1).Parameters)) {
	& $BuildFile
	throw 'Invalid script.'
}
if ($_.Count) {&{
	($a = New-Object System.Collections.ObjectModel.Collection[Attribute]).Add((New-Object System.Management.Automation.ParameterAttribute))
	$c = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'ErrorVariable', 'WarningVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable', 'InformationAction', 'InformationVariable'
	$r = 'Task', 'File', 'Checkpoint', 'Result', 'Safe', 'Summary', 'Resume', 'WhatIf'
	foreach($p in $_.Values) {
		if ($c -notcontains ($_ = $p.Name)) {
			if ($r -contains $_) {throw "Script uses reserved parameter '$_'."}
			${*}.DP.Add($_, (New-Object System.Management.Automation.RuntimeDefinedParameter $_, $p.ParameterType, $a))
		}
	}
	${*}.DP
}}

} end {

#.ExternalHelp Invoke-Build-Help.xml
function Add-BuildTask(
	[Parameter(Position=0, Mandatory=1)][string]$Name,
	[Parameter(Position=1)][object[]]$Jobs,
	[object[]]$After,
	[object[]]$Before,
	$If=$true,
	$Inputs,
	$Outputs,
	$Data,
	$Done,
	$Source=$MyInvocation,
	[switch]$Partial
)
{
	if ($_ = ${*}.All[$Name]) {${*}.Redefined += $_}
	${*}.All[$Name] = [PSCustomObject]@{
		Name = $Name
		Error = $null
		Started = $null
		Elapsed = $null
		Jobs = $1 = [System.Collections.Generic.List[object]]@()
		Safe = $2 = [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}
	trap {*Die "Task '$Name': $_" 5}
	foreach($_ in $Jobs) {
		$r, $d = *Job $_
		if ($1 -contains $r) {${*}.Doubles += ,($Name, $r)}
		$1.Add($r)
		if (1 -eq $d) {
			$2.Add($r)
		}
	}
}

#.ExternalHelp Invoke-Build-Help.xml
function New-BuildJob([Parameter(Mandatory=1)][string]$Name, [switch]$Safe) {
	if ($Safe) {@{$Name = 1}} else {$Name}
}

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

#.ExternalHelp Invoke-Build-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 Invoke-Build-Help.xml
function Get-BuildError([Parameter(Mandatory=1)][string]$Task) {
	if (!($_ = ${*}.All[$Task])) {
		*Die "Missing task '$Task'." 13
	}
	$_.Error
}

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

#.ExternalHelp Invoke-Build-Help.xml
function Invoke-BuildExec([Parameter(Mandatory=1)][scriptblock]$Command, [int[]]$ExitCode=0) {
	${private:*c} = $Command
	${private:*x} = $ExitCode
	Remove-Variable Command, ExitCode
	& ${*c}
	if (${*x} -notcontains $global:LastExitCode) {
		*Die "Command {${*c}} exited with code $global:LastExitCode." 8
	}
}

#.ExternalHelp Invoke-Build-Help.xml
function Test-BuildAsset([Parameter(Position=0)][string[]]$Variable, [string[]]$Environment, [string[]]$Property) {
	Remove-Variable Variable, Environment, Property
	if ($_ = $PSBoundParameters['Variable']) {foreach($_ in $_) {
		if ($null -eq ($$ = $PSCmdlet.GetVariableValue($_)) -or '' -eq $$) {*Die "Missing variable '$_'." 13}
	}}
	if ($_ = $PSBoundParameters['Environment']) {foreach($_ in $_) {
		if (!([Environment]::GetEnvironmentVariable($_))) {*Die "Missing environment variable '$_'." 13}
	}}
	if ($_ = $PSBoundParameters['Property']) {foreach($_ in $_) {
		if ('' -eq (Get-BuildProperty $_ '')) {*Die "Missing property '$_'." 13}
	}}
}

#.ExternalHelp Invoke-Build-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\$_"}
		^VisualStudio\\ {
			$x = if ([IntPtr]::Size -eq 8) {'\Wow6432Node'}
			[Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE$x\Microsoft\$_", 'InstallDir', '')
		}
		default {*Path $_}
	}
	if (![System.IO.Directory]::Exists($d)) {throw "Cannot resolve '$Path'."}
	foreach($_ in $Name) {
		Set-Alias $_ (Join-Path $d $_) -Scope 1
	}
}

#.ExternalHelp Invoke-Build-Help.xml
function Write-Build([ConsoleColor]$Color, [string]$Text) {
	$i = $Host.UI.RawUI
	$_ = $i.ForegroundColor
	try {
		$i.ForegroundColor = $Color
		$Text
	}
	finally {
		$i.ForegroundColor = $_
	}
}
try {
	$null = Write-Build 0
}
catch {
	function Write-Build($Color, [string]$Text) {$Text}
}

#.ExternalHelp Invoke-Build-Help.xml
function Get-BuildVersion {[Version]'3.6.5'}

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

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

function *Run($_) {
	if ($_ -and !$WhatIf) {
		*SL
		. $_ @args
	}
}

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

function *Error($M, $I) {
@"
$M
$(*At $I)
"@
}

function *Job($J) {
	if ($J -is [scriptblock] -or $J -is [string]) {
		$J
	}
	elseif ($J -is [hashtable] -and $J.Count -eq 1) {
		$J.Keys
		$J.Values
	}
	else {throw 'Invalid job.'}
}

function *Unsafe($N, $J, $X) {
	foreach($_ in $J) {
		if (($t = ${*}.All[$_]) -and $t.If -and $(if ($_ -eq $N) {$X -notcontains $_} else {*Unsafe $N $t.Jobs $t.Safe})) {
			return 1
		}
	}
}

function *Amend([Parameter()]$X, $J, $B) {
	trap {*Die (*Error "Task '$n': $_" $X) 5}
	$n = $X.Name
	foreach($_ in $J) {
		$r, $d = *Job $_
		if (!($t = ${*}.All[$r])) {throw "Missing task '$r'."}
		$j = $t.Jobs
		$i = $j.Count
		if ($B) {
			for($k = -1; ++$k -lt $i -and $j[$k] -is [string]) {}
			$i = $k
		}
		$j.Insert($i, $n)
		if (1 -eq $d) {
			$t.Safe.Add($n)
		}
	}
}

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

function *Save {
	Export-Clixml ${*}.Checkpoint -InputObject @{
		User = *Run ${*}.Export
		Task = $BuildTask
		File = $BuildFile
		Prm1 = ${*}.SP
		Prm2 = $(
			$r = @{}
			foreach($_ in ${*}.DP.Keys) {
				$r[$_] = Get-Variable -Name $_ -Scope Script -ValueOnly
			}
			$r
		)
		Done = @(foreach($t in ${*}.All.Values) {if ($t.Elapsed) {$t.Name}})
	}
}

function *AddError($T) {
	${*}.Errors.Add([PSCustomObject]@{Error = $_; File = $BuildFile; Task = $T})
}

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.Keys
	$h = @{}
	foreach($_ in $A.Values) {foreach($_ in $_.Jobs) {if ($_ -is [string]) {$h[$_] = 1}}}
	foreach($_ in $A.Keys) {if (!$h[$_]) {$_}}
}

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) {throw "Missing Inputs item: '$_'."}
		$_
		${*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) {throw "Different Inputs/Outputs counts: $(${*p}.Count)/$(${*o}.Count)."}

		$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}) {throw 'Outputs must not be empty.'}

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

function *Task {
	New-Variable -Name Task -Option Constant -Value (${*}.Task = ${*}.All[$args[0]])
	${private:*p} = $args[1] + '/' + $Task.Name

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

	if (${*}.Checkpoint) {*Save}
	if ((${private:*x} = $Task.If) -is [scriptblock] -and !$WhatIf) {
		*SL
		try {
			${*x} = & ${*x}
		}
		catch {
			$Task.Error = $_
			throw
		}
	}
	if (!${*x}) {
		Write-Build 8 "Task ${*p} skipped."
		return
	}

	${private:*i} = , [int]($null -ne $Task.Inputs)
	$Task.Started = [DateTime]::Now
	try {
		. *Run ${*}.EnterTask
		foreach(${private:*j} in $Task.Jobs) {
			if (${*j} -is [string]) {
				try {
					*Task ${*j} ${*p}
				}
				catch {
					if (*Unsafe ${*j} $BuildTask) {throw}
					*AddError ${*}.All[${*j}]
					Write-Build 12 "ERROR: $(if (*My) {$_} else {*Error $_ $_})"
				}
				continue
			}

			& ${*}.Header ${*p}
			if ($WhatIf) {
				${*j}
				continue
			}

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

			try {
				. *Run ${*}.EnterJob
				*SL
				if (0 -eq ${*i}[0]) {
					& ${*j}
				}
				else {
					$Inputs = $Task.Inputs
					$Outputs = $Task.Outputs
					if ($Task.Partial) {
						${*x} = 0
						$Inputs | .{process{
							$2 = $Outputs[${*x}++]
							$_
						}} | & ${*j}
					}
					else {
						$Inputs | & ${*j}
					}
				}
			}
			catch {
				$Task.Error = $_
				throw
			}
			finally {
				. *Run ${*}.ExitJob
			}
		}
		$Task.Elapsed = [DateTime]::Now - $Task.Started
		if ($_ = $Task.Error) {
			*AddError $Task
			Write-Build 14 (*At $Task)
			Write-Build 12 "ERROR: $(*Error $_ $_)"
		}
		else {
			Write-Build 11 "Done ${*p} $($Task.Elapsed)"
		}
		*Run $Task.Done
	}
	catch {
		$Task.Elapsed = [DateTime]::Now - $Task.Started
		$Task.Error = $_
		Write-Build 14 (*At $Task)
		throw
	}
	finally {
		${*}.Tasks.Add($Task)
		. *Run ${*}.ExitTask
	}
}

Set-Alias assert Assert-Build
Set-Alias equals Assert-BuildEquals
Set-Alias error Get-BuildError
Set-Alias exec Invoke-BuildExec
Set-Alias job New-BuildJob
Set-Alias property Get-BuildProperty
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 Invoke-Builds (Join-Path $_ Invoke-Builds.ps1)
Set-Alias Resolve-MSBuild (Join-Path $_ Resolve-MSBuild.ps1)

if ($MyInvocation.InvocationName -eq '.') {
	if ($_ = $MyInvocation.ScriptName) {
		$ErrorActionPreference = 'Stop'
		$BuildFile = $_
		*SL ($BuildRoot = if ($Task) {*Path $Task} else {Split-Path $_})
	}
	Remove-Variable Task, File, Checkpoint, Result, Safe, Summary, Resume, WhatIf
	return
}

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

$ErrorActionPreference = 'Stop'
if (!${*}.SP) {
	${*}.SP = @{}
	foreach($_ in $PSBoundParameters.Keys) {
		if (${*}.DP.ContainsKey($_)) {
			${*}.SP[$_] = $PSBoundParameters[$_]
		}
	}
}
if (${*}.Q = $BuildTask -eq '??' -or $BuildTask -eq '?') {
	$WhatIf = $true
}
if ($Result) {
	if ($Result -is [string]) {
		New-Variable -Force -Scope 1 $Result ${*}
	}
	else {
		$Result.Value = ${*}
	}
}
Remove-Variable Task, File, Checkpoint, Result, Safe, Summary, Resume

try {
	if ($BuildTask -eq '**') {
		${*}.A = 0
		foreach($_ in $BuildFile) {
			Invoke-Build @('*'; $BuildTask -ne '**') $_.FullName -Safe:${*}.Safe
		}
		${*}.B = 1
		return
	}

	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 Export-Build([Parameter()][scriptblock]$Script) {${*}.Export = $Script}
	function Import-Build([Parameter()][scriptblock]$Script) {${*}.Import = $Script}
	function Set-BuildHeader([Parameter()][scriptblock]$Script) {${*}.Header = $Script}

	*SL ($BuildRoot = if ($BuildFile) {Split-Path $BuildFile} else {${*}.CD})
	$_ = ${*}.SP
	${private:**} = @(. ${*}.File @_)
	foreach($_ in ${**}) {
		Write-Warning "Unexpected output: $_."
		if ($_ -is [scriptblock]) {throw "Dangling scriptblock at $($_.File):$($_.StartPosition.StartLine)"}
	}
	if (!(${**} = ${*}.All).Count) {throw "No tasks in '$BuildFile'."}

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

	if (${*}.Q) {
		*Check ${**}.Keys
		if ($BuildTask -eq '??') {
			${**}
		}
		else {
			${**}.Values | *Help
		}
		return
	}

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

	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 (${*}.CP) {
			foreach($_ in ${*}.CP.Done) {
				${**}[$_].Elapsed = [TimeSpan]::Zero
			}
			foreach($_ in ${*}.CP.Prm2.GetEnumerator()) {
				Set-Variable $_.Key $_.Value
			}
			. *Run ${*}.Import ${*}.CP.User
		}
		foreach($_ in $BuildTask) {
			*Task $_ ''
		}
		${*}.Task = $null
		if (${*}.Checkpoint) {
			[System.IO.File]::Delete(${*}.Checkpoint)
		}
	}
	finally {
		. *Run ${*}.ExitBuild
	}
	${*}.B = 1
	exit 0
}
catch {
	${*}.B = 2
	${*}.Error = $_
	*AddError ${*}.Task
	if ($_.FullyQualifiedErrorId -eq 'PositionalParameterNotFound,Add-BuildTask') {
		Write-Warning 'Check task positional parameters: a name and comma separated jobs.'
	}
	if (${*}.Safe) {
		Write-Build 12 (*Error "ERROR: $_" $_)
	}
	else {
		if (*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 {*Error $_ $_})"
				}
			}
		}
		if ($w = ${*}.Warnings) {
			foreach($_ in $w) {
				"WARNING: $($_.Message)$(if ($_.Task) {" Task: $($_.Task.Name)."}) File: $($_.File)."
			}
		}
		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\3.6.5\Invoke-Builds.ps1

<#
Copyright 2011-2017 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 Invoke-Build-Help.xml
param(
	[Parameter(Position=0)][hashtable[]]$Build,
	$Result,
	[int]$Timeout=[int]::MaxValue,
	[int]$MaximumBuilds=[Environment]::ProcessorCount
)

# 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}

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

### works
$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.Title = "($1/$($Build.Count)) $file"
}

# runspace pool
if ($MaximumBuilds -lt 1) {*Die "MaximumBuilds should be a positive number." 5}
$pool = [RunspaceFactory]::CreateRunspacePool(1, $MaximumBuilds)
$failures = @()

try {
	### begin
	$pool.Open()
	foreach($work in $works) {
		$b = $work.Build

		# log
		if ($log = $b['Log']) {
			$b.Remove('Log')
			[System.IO.File]::Delete(($log = *Path $log))
		}
		else {
			$work.Temp = $true
			$log = [System.IO.Path]::GetTempFileName()
		}
		$work.Log = $log

		# PS
		$work.PS = $ps = [PowerShell]::Create()
		$ps.RunspacePool = $pool
		$work.Job =
		$ps.AddCommand($ib).AddParameters($b).AddCommand('Out-File').AddParameter('FilePath', $log).AddParameter('Encoding', 'UTF8').BeginInvoke()
	}

	### wait
	$stopwatch = [Diagnostics.Stopwatch]::StartNew()
	foreach($work in $works) {
		Write-Build Cyan $work.Title
		$t = $Timeout - $stopwatch.ElapsedMilliseconds
		$work.Done = if ($t -gt 0) {$work.Job.AsyncWaitHandle.WaitOne($t)}
	}

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

		$ps = $work.PS
		$exception = $null
		try {
			if ($work.Done) {
				$ps.EndInvoke($work.Job)
			}
			else {
				$ps.Stop()
				$exception = 'Build timed out.'
			}
		}
		catch {
			$exception = $_
		}

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

		# result, error
		$_ = if ($r = $work.Build.Result['Value']) {
			$r.Error
			$info.Tasks.AddRange($r.Tasks)
			$info.Errors.AddRange($r.Errors)
			$info.Warnings.AddRange($r.Warnings)
		}
		else {
			"'$($work.Build.File)' invocation failed: $exception"
		}
		if (!$_) {
			$_ = $exception
		}
		if ($_) {
			Write-Build Cyan "Build $($work.Title) FAILED."
			$_ = if ($_ -is [System.Management.Automation.ErrorRecord]) {*Error $_ $_} 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 "`r`n")
	}
}
finally {
	$pool.Close()
	$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\3.6.5\InvokeBuild.psd1
@{
	ModuleVersion = '3.6.5'
	ModuleToProcess = 'InvokeBuild.psm1'
	GUID = 'a0319025-5f1f-47f0-ae8d-9c7e151a5aae'
	Author = 'Roman Kuzmin'
	CompanyName = 'Roman Kuzmin'
	Copyright = '(c) 2011-2017 Roman Kuzmin'
	Description = 'Build and test automation in PowerShell'
	PowerShellVersion = '2.0'
	AliasesToExport = @('Invoke-Build', 'Invoke-Builds')
	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/master/ib.png'
			ReleaseNotes = 'https://github.com/nightroman/Invoke-Build/blob/master/Release-Notes.md'
		}
	}
}
tools\InvokeBuild\3.6.5\InvokeBuild.psm1

Set-Alias -Name Invoke-Build -Value (Join-Path $PSScriptRoot Invoke-Build.ps1)
Set-Alias -Name Invoke-Builds -Value (Join-Path $PSScriptRoot Invoke-Builds.ps1)
Export-ModuleMember -Alias Invoke-Build, Invoke-Builds
tools\InvokeBuild\3.6.5\LICENSE.txt
Invoke-Build - Build Automation in PowerShell
Copyright (c) 2011-2017 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.
tools\InvokeBuild\3.6.5\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>
      <Version N="Version">3.6.5</Version>
      <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) 2011-2017 Roman Kuzmin</S>
      <DT N="PublishedDate">2017-08-29T18:58:34+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/master/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/master/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">
        <TNRef RefId="2" />
        <DCT>
          <En>
            <S N="Key">releaseNotes</S>
            <S N="Value">https://github.com/nightroman/Invoke-Build/blob/master/Release-Notes.md</S>
          </En>
          <En>
            <S N="Key">versionDownloadCount</S>
            <S N="Value">14</S>
          </En>
          <En>
            <S N="Key">ItemType</S>
            <S N="Value">Module</S>
          </En>
          <En>
            <S N="Key">copyright</S>
            <S N="Value">(c) 2011-2017 Roman Kuzmin</S>
          </En>
          <En>
            <S N="Key">CompanyName</S>
            <S N="Value">Roman Kuzmin</S>
          </En>
          <En>
            <S N="Key">tags</S>
            <S N="Value">Build Test Automation PSModule</S>
          </En>
          <En>
            <S N="Key">created</S>
            <S N="Value">8/29/2017 6:58:34 PM +00:00</S>
          </En>
          <En>
            <S N="Key">description</S>
            <S N="Value">Build and test automation in PowerShell</S>
          </En>
          <En>
            <S N="Key">published</S>
            <S N="Value">8/29/2017 6:58:34 PM +00:00</S>
          </En>
          <En>
            <S N="Key">developmentDependency</S>
            <S N="Value">False</S>
          </En>
          <En>
            <S N="Key">NormalizedVersion</S>
            <S N="Value">3.6.5</S>
          </En>
          <En>
            <S N="Key">downloadCount</S>
            <S N="Value">7108</S>
          </En>
          <En>
            <S N="Key">GUID</S>
            <S N="Value">a0319025-5f1f-47f0-ae8d-9c7e151a5aae</S>
          </En>
          <En>
            <S N="Key">PowerShellVersion</S>
            <S N="Value">2.0</S>
          </En>
          <En>
            <S N="Key">updated</S>
            <S N="Value">2017-08-30T04:03:33Z</S>
          </En>
          <En>
            <S N="Key">isLatestVersion</S>
            <S N="Value">True</S>
          </En>
          <En>
            <S N="Key">IsPrerelease</S>
            <S N="Value">false</S>
          </En>
          <En>
            <S N="Key">isAbsoluteLatestVersion</S>
            <S N="Value">True</S>
          </En>
          <En>
            <S N="Key">packageSize</S>
            <S N="Value">30523</S>
          </En>
          <En>
            <S N="Key">FileList</S>
            <S N="Value">InvokeBuild.nuspec|about_InvokeBuild.help.txt|ib.cmd|Invoke-Build-Help.xml|Invoke-Build.ps1|Invoke-Builds.ps1|InvokeBuild.psd1|InvokeBuild.psm1|LICENSE.txt|README.htm|Release-Notes.htm|Resolve-MSBuild.ps1</S>
          </En>
          <En>
            <S N="Key">requireLicenseAcceptance</S>
            <S N="Value">True</S>
          </En>
        </DCT>
      </Obj>
      <S N="InstalledLocation">C:\projects\au-packages\invoke-build\tools\InvokeBuild\3.6.5</S>
    </MS>
  </Obj>
</Objs>
tools\InvokeBuild\3.6.5\README.htm
 
tools\InvokeBuild\3.6.5\Release-Notes.htm
 
tools\InvokeBuild\3.6.5\Resolve-MSBuild.ps1

<#PSScriptInfo
.VERSION 1.2.0
.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 to work for MSBuild 2.0-15.0 and support future versions.

	For MSBuild 15.0+ the command uses VSSetup module from PSGallery.
	If it is not installed then some default locations are checked.
	Thus, VSSetup module is required for not default installations.

	MSBuild 15.0+ resolution precedence: Enterprise, Professional, Community,
	another product. If this is not suitable then use VSSetup module directly.

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

.Parameter Version
		Specifies the required MSBuild version. If it is omitted, empty, or *
		then the command finds and returns the latest installed version path.
		The optional suffix x86 tells to use 32-bit MSBuild.

.Outputs
	The full path to MSBuild.exe

.Example
	Resolve-MSBuild 15.0
	Gets location of MSBuild installed with Visual Studio 2017.

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

[CmdletBinding()]
param(
	[string]$Version
)

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

function Get-MSBuild15VSSetup($Bitness) {
	if (!(Get-Module VSSetup -ListAvailable)) {return}
	Import-Module VSSetup

	$vs = Get-VSSetupInstance | Select-VSSetupInstance -Version 15.0 -Require Microsoft.Component.MSBuild -Product *
	if (!$vs) {return}

	$vs = if ($r = $vs | Select-VSSetupInstance -Product Microsoft.VisualStudio.Product.Enterprise) {$r}
	elseif ($r = $vs | Select-VSSetupInstance -Product Microsoft.VisualStudio.Product.Professional) {$r}
	elseif ($r = $vs | Select-VSSetupInstance -Product Microsoft.VisualStudio.Product.Community) {$r}
	else {$vs}

	if ($vs) {
		Join-Path @($vs)[0].InstallationPath (Get-MSBuild15Path $Bitness)
	}
}

function Get-MSBuild15Guess($Bitness) {
	if (!($root = ${env:ProgramFiles(x86)})) {$root = $env:ProgramFiles}
	if (!(Test-Path -LiteralPath "$root\Microsoft Visual Studio\2017")) {return}

	$paths = @(
		foreach($_ in Resolve-Path "$root\Microsoft Visual Studio\2017\*\$(Get-MSBuild15Path $Bitness)" -ErrorAction 0) {
			$_.ProviderPath
		}
	)

	if ($paths) {
		if ($r = $paths -like '*\Enterprise\*') {return $r}
		if ($r = $paths -like '*\Professional\*') {return $r}
		if ($r = $paths -like '*\Community\*') {return $r}
		$paths[0]
	}
}

function Get-MSBuild15($Bitness) {
	if ($path = Get-MSBuild15VSSetup $Bitness) {
		$path
	}
	else {
		Get-MSBuild15Guess $Bitness
	}
}

function Get-MSBuildOldVersion($Version, $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($Bitness) {
	$rp = @(Get-ChildItem HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions | Sort-Object {[Version]$_.PSChildName})
	if ($rp) {
		Get-MSBuildOldVersion $rp[-1].PSChildName $Bitness
	}
}

$ErrorActionPreference = 1
try {
	if ($Version -match '^(.*?)(x86)$') {
		$Version = $matches[1]
		$Bitness = $matches[2]
	}
	else {
		$Bitness = ''
	}

	$v15 = [Version]'15.0'
	$vMax = [Version]'9999.0'
	if (!$Version) {$Version = '*'}
	$vRequired = if ($Version -eq '*') {$vMax} else {[Version]$Version}

	if ($vRequired -eq $v15) {
		if ($path = Get-MSBuild15 $Bitness) {
			return $path
		}
	}
	elseif ($vRequired -lt $v15) {
		if ($path = Get-MSBuildOldVersion $Version $Bitness) {
			return $path
		}
	}
	elseif ($vRequired -eq $vMax) {
		if ($path = Get-MSBuild15 $Bitness) {
			return $path
		}
		if ($path = Get-MSBuildOldLatest $Bitness) {
			return $path
		}
	}

	throw 'The specified version is not found.'
}
catch {
	Write-Error "Cannot resolve MSBuild $Version : $_"
}
tools\New-VSCodeTask.ps1

<#PSScriptInfo
.VERSION 1.1.2
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) 2011-2017 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

.Description
	The script creates "./.vscode/tasks.json". The existing file is replaced.
	Change to the VSCode workspace directory before invoking the script.
	Generated VSCode tasks call Invoke-Build tasks.

	Do not edit "tasks.json" directly. Edit the build script instead. When you
	add, remove, rename tasks, or change script locations 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 the Invoke-Build.ps1 path, absolute or relative. If it is not
		specified then any found in the workspace is used. If there is none
		then the command Invoke-Build is used.

.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.
#>

[CmdletBinding()]
param(
	[string]$BuildFile,
	[string]$InvokeBuild
)

function Add-Text($Text) {$null = $out.Append($Text)}
function Add-Line($Text) {$null = $out.AppendLine($Text)}

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

# resolve Invoke-Build.ps1
if (!$InvokeBuild) {
	$InvokeBuild2 = @(Get-ChildItem . -Name -Recurse -Filter Invoke-Build.ps1)
	$InvokeBuild = if ($InvokeBuild2) {
		'./{0}' -f $InvokeBuild2[0]
	} else {
		'Invoke-Build'
	}
}
$InvokeBuild2 = if ($InvokeBuild -eq 'Invoke-Build') {
	'Invoke-Build'
}
else {
	"& '{0}'" -f $InvokeBuild.Replace('\', '/').Replace("'", "''")
}

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

# tasks.json header
$out = New-Object System.Text.StringBuilder
Add-Line '// Do not edit! This file is generated by New-VSCodeTask.ps1'
Add-Line '// Modify the build script instead and regenerate this file.'
Add-Line '{'
Add-Line '  "version": "2.0.0",'
Add-Line '  "suppressTaskName": true,'
Add-Line '  "windows": {'
Add-Line '    "command": "powershell.exe",'
Add-Line '    "args": [ "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command" ]'
Add-Line '  },'
Add-Line '  "linux": {'
Add-Line '    "command": "/usr/bin/powershell",'
Add-Line '    "args": [ "-NoProfile", "-Command" ]'
Add-Line '  },'
Add-Line '  "osx": {'
Add-Line '    "command": "/usr/local/bin/powershell",'
Add-Line '    "args": [ "-NoProfile", "-Command" ]'
Add-Line '  },'
Add-Line '  "tasks": ['

# tasks.json tasks
$BuildFile2 = if ($BuildFile) {" -File '{0}'" -f $BuildFile.Replace('\', '/').Replace("'", "''")} else {''}
foreach($task in $all.Values) {
	$name = $task.Name
	if ($name -match '[^\w\.\-]|^-') {
		continue
	}
	Add-Line '    {'
	Add-Line ('      "taskName": "{0}",' -f $name)
	Add-Line '      "problemMatcher": ['
	Add-Line '        "$msCompile"'
	Add-Line '      ],'
	if ($name -eq $dot) {
		Add-Line '      "group": {'
		Add-Line '        "kind": "build",'
		Add-Line '        "isDefault": true'
		Add-Line '      },'
	}
	Add-Line ('      "args": [ "{0} -Task {1}{2}" ]' -f $InvokeBuild2, $name, $BuildFile2)
	Add-Line '    },'
}

# last task and ending
Add-Line '    {'
Add-Line '      "taskName": "?",'
Add-Line '      "problemMatcher": [],'
Add-Line ('      "args": [ "{0} -Task ?{1}" ]' -f $InvokeBuild2, $BuildFile2)
Add-Line '    }'
Add-Line '  ]'
Add-Text '}'

# save the file
if (!(Test-Path .vscode)) {
	$null = mkdir .vscode
}
Set-Content ./.vscode/tasks.json $out.ToString() -Encoding UTF8

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 7 Thursday, November 21, 2024 Ready
Invoke-Build 5.11.2 114 Wednesday, June 12, 2024 Approved
Invoke-Build 5.11.1 209 Sunday, April 14, 2024 Approved
Invoke-Build 5.11.0 206 Saturday, March 9, 2024 Approved
Invoke-Build 5.10.6 47 Tuesday, March 5, 2024 Approved
Invoke-Build 5.10.5 327 Saturday, December 16, 2023 Approved
Invoke-Build 5.10.4 828 Tuesday, May 16, 2023 Approved
Invoke-Build 5.10.3 348 Friday, March 10, 2023 Approved
Invoke-Build 5.10.2 129 Thursday, February 9, 2023 Approved
Invoke-Build 5.10.1 427 Tuesday, October 25, 2022 Approved
Invoke-Build 5.10.0 129 Saturday, October 22, 2022 Approved
Invoke-Build 5.9.12 808 Saturday, September 17, 2022 Approved
Invoke-Build 5.9.11 597 Sunday, August 21, 2022 Approved
Invoke-Build 5.9.10 1694 Tuesday, April 12, 2022 Approved
Invoke-Build 5.9.9.0 606 Thursday, March 10, 2022 Approved
Invoke-Build 5.9.8 138 Monday, March 7, 2022 Approved
Invoke-Build 5.9.7 400 Thursday, February 10, 2022 Approved
Invoke-Build 5.9.6 163 Saturday, February 5, 2022 Approved
Invoke-Build 5.9.5 101 Friday, February 4, 2022 Approved
Invoke-Build 5.9.4 137 Wednesday, February 2, 2022 Approved
Invoke-Build 5.9.3 131 Saturday, January 29, 2022 Approved
Invoke-Build 5.9.2 97 Friday, January 28, 2022 Approved
Invoke-Build 5.9.1 106 Thursday, January 27, 2022 Approved
Invoke-Build 5.9.0 244 Monday, January 17, 2022 Approved
Invoke-Build 5.8.8 276 Sunday, January 2, 2022 Approved
Invoke-Build 5.8.7 242 Monday, December 13, 2021 Approved
Invoke-Build 5.8.6 309 Thursday, November 25, 2021 Approved
Invoke-Build 5.8.5 356 Wednesday, November 10, 2021 Approved
Invoke-Build 5.8.4 1085 Sunday, August 15, 2021 Approved
Invoke-Build 5.8.3 92 Saturday, August 14, 2021 Approved
Invoke-Build 5.8.1 193 Sunday, July 18, 2021 Approved
Invoke-Build 5.8.0 998 Friday, April 16, 2021 Approved
Invoke-Build 5.7.3 300 Saturday, March 27, 2021 Approved
Invoke-Build 5.7.2 497 Sunday, March 7, 2021 Approved
Invoke-Build 5.7.1 220 Saturday, February 27, 2021 Approved
Invoke-Build 5.7.0 252 Saturday, February 20, 2021 Approved
Invoke-Build 5.6.5 924 Monday, January 11, 2021 Approved
Invoke-Build 5.6.4 248 Thursday, December 17, 2020 Approved
Invoke-Build 5.6.3 516 Monday, November 23, 2020 Approved
Invoke-Build 5.6.2 610 Friday, September 11, 2020 Approved
Invoke-Build 5.6.1 238 Friday, August 7, 2020 Approved
Invoke-Build 5.6.0 715 Thursday, May 21, 2020 Approved
Invoke-Build 5.5.11 285 Tuesday, April 28, 2020 Approved
Invoke-Build 5.5.9 261 Wednesday, April 8, 2020 Approved
Invoke-Build 5.5.8 368 Tuesday, March 24, 2020 Approved
Invoke-Build 5.5.7 339 Friday, February 7, 2020 Approved
Invoke-Build 5.5.6 225 Monday, December 16, 2019 Approved
Invoke-Build 5.5.5 241 Thursday, October 17, 2019 Approved
Invoke-Build 5.5.3 267 Friday, August 30, 2019 Approved
Invoke-Build 5.5.2 249 Wednesday, June 12, 2019 Approved
Invoke-Build 5.5.1 259 Wednesday, April 10, 2019 Approved
Invoke-Build 5.5.0 233 Thursday, April 4, 2019 Approved
Invoke-Build 5.4.6 192 Thursday, March 28, 2019 Approved
Invoke-Build 5.4.5 260 Wednesday, March 6, 2019 Approved
Invoke-Build 5.4.4 234 Monday, February 25, 2019 Approved
Invoke-Build 5.4.3 247 Friday, February 15, 2019 Approved
Invoke-Build 5.4.2 656 Saturday, December 8, 2018 Approved
Invoke-Build 5.4.1 693 Thursday, April 12, 2018 Approved
Invoke-Build 5.4.0 346 Tuesday, April 3, 2018 Approved
Invoke-Build 5.3.0 340 Saturday, March 24, 2018 Approved
Invoke-Build 5.2.1 335 Tuesday, March 20, 2018 Approved
Invoke-Build 5.2.0 355 Tuesday, February 27, 2018 Approved
Invoke-Build 5.1.1 334 Thursday, February 15, 2018 Approved
Invoke-Build 5.1.0 326 Thursday, February 8, 2018 Approved
Invoke-Build 5.0.1 370 Tuesday, January 16, 2018 Approved
Invoke-Build 5.0.0 358 Tuesday, January 2, 2018 Approved
Invoke-Build 4.2.0 345 Wednesday, December 20, 2017 Approved
Invoke-Build 4.1.2 396 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 337 Thursday, November 23, 2017 Approved
Invoke-Build 4.0.0 378 Wednesday, November 15, 2017 Approved
Invoke-Build 3.7.2 382 Tuesday, November 7, 2017 Approved
Invoke-Build 3.7.1 408 Sunday, October 29, 2017 Approved
Invoke-Build 3.6.5.20170830 470 Wednesday, August 30, 2017 Approved
Invoke-Build 3.6.4 444 Saturday, July 29, 2017 Approved
Invoke-Build 3.6.3 346 Thursday, July 27, 2017 Approved
Invoke-Build 3.6.2 371 Friday, July 21, 2017 Approved
Invoke-Build 3.6.1 385 Saturday, July 15, 2017 Approved
Invoke-Build 3.6.0 376 Saturday, July 8, 2017 Approved
Invoke-Build 3.5.3 399 Friday, June 30, 2017 Approved
Invoke-Build 3.5.2 382 Tuesday, June 27, 2017 Approved
Invoke-Build 3.5.1 417 Thursday, June 22, 2017 Approved
Invoke-Build 3.5.0 353 Saturday, June 17, 2017 Approved
Invoke-Build 3.4.0 385 Thursday, June 8, 2017 Approved
Invoke-Build 3.3.11 382 Friday, June 2, 2017 Approved
Invoke-Build 3.3.10 395 Friday, May 26, 2017 Approved
Invoke-Build 3.3.9 358 Saturday, May 20, 2017 Approved
Invoke-Build 3.3.8 457 Friday, May 12, 2017 Approved
Invoke-Build 3.3.7 364 Tuesday, May 9, 2017 Approved
Invoke-Build 3.3.6 355 Sunday, April 30, 2017 Approved
Invoke-Build 3.3.5 400 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