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:

32,589

Downloads of v 3.3.9:

343

Last Update:

20 May 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.3.9 | Updated: 20 May 2017

Downloads:

32,589

Downloads of v 3.3.9:

343

Maintainer(s):

Software Author(s):

  • Roman Kuzmin

Invoke-Build 3.3.9

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

  • 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.3.9'" [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.3.9'" 
$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.3.9'
    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.3.9'
end

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


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

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


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

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


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved as a trusted package on 20 May 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.


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

Write-Host "Installing module $moduleName to $Env:ProgramFiles\WindowsPowerShell\Modules"
cp $toolsDir\$moduleName $Env:ProgramFiles\WindowsPowerShell\Modules -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\InvokeBuild\3.3.9\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.3.9\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 "& '%~dp0Invoke-Build.ps1' %*"
exit /B %errorlevel%

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

:help
PowerShell.exe -NoProfile -ExecutionPolicy Bypass "help -Full '%~dp0Invoke-Build.ps1'"
exit /B 0
tools\InvokeBuild\3.3.9\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 events. 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-BuildVersion
    Invoke-BuildExec (exec)
    New-BuildJob (job)
    Resolve-MSBuild
    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 events Enter|Exit-BuildTask, Enter|Exit-BuildJob.

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

EVENT BLOCKS

Scripts may define the following event 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

Events are not called on WhatIf.
Nested builds do not inherit parent events.
If Enter-X is called then Exit-X is called.

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
    - 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">String</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.</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 event functions. But build scripts
should not output anything. Unexpected output is shown as a warning,
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>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 the 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:

    - PowerShell 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

CAUTION: Properties should be used sparingly with carefully chosen names
that unlikely can already exist and be not related to the build script.</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 to be used if the variable is not found.
Omitted or null values require the variable to exist and be not null.
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>
</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>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.

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.3.9\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)][string]$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}

$BuildTask = $PSBoundParameters['Task']
$BuildFile = $PSBoundParameters['File']
${private:*Checkpoint} = $PSBoundParameters['Checkpoint']
${private:*Resume} = $PSBoundParameters['Resume']
${private:*cd} = *Path
${private:*cp} = $null
${private:*p1} = $null
${private:*r} = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
${private:*pp} = 'Task', 'File', 'Parameters', 'Checkpoint', 'Result', 'Safe', 'Summary', 'Resume', 'WhatIf'
${private:*pn} = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'ErrorVariable', 'WarningVariable', 'OutVariable', 'OutBuffer',
'PipelineVariable', 'InformationAction', 'InformationVariable'

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 (${*Resume}) {
	if (!${*Checkpoint}) {throw 'Checkpoint must be defined for Resume.'}
	${*cp} = try {Import-Clixml ${*Checkpoint}} catch {throw 'Invalid checkpoint file?'}
	$BuildTask = ${*cp}.Task
	$BuildFile = ${*cp}.File
	${*p1} = ${*cp}.Prm1
}
elseif ($BuildFile) {
	if (![System.IO.File]::Exists(($BuildFile = *Path $BuildFile))) {throw "Missing script '$BuildFile'."}
}
elseif (!($BuildFile = Get-BuildFile ${*cd})) {
	throw 'Missing default script.'
}

if (!($_ = (Get-Command $BuildFile -ErrorAction 1).Parameters)) {
	& $BuildFile
	throw 'Invalid script.'
}
if (!$_.Count) {return}

(${private:*a} = New-Object System.Collections.ObjectModel.Collection[Attribute]).Add((New-Object System.Management.Automation.ParameterAttribute))
foreach(${private:*b} in $_.Values) {
	if (${*pn} -notcontains ($_ = ${*b}.Name)) {
		if (${*pp} -contains $_) {throw "Script uses reserved parameter '$_'."}
		${*r}.Add($_, (New-Object System.Management.Automation.RuntimeDefinedParameter $_, ${*b}.ParameterType, ${*a}))
	}
}
${*r}

} 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.Add($_)}
	${*}.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 $_
		$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) {
	if (($null -eq ($_ = $PSCmdlet.GetVariableValue($Name)) -or '' -eq $_ ) -and !($_ = [Environment]::GetEnvironmentVariable($Name)) -and $null -eq ($_ = $Value)) {
		*Die "Missing variable '$Name'." 13
	}
	$_
}

#.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 Use-BuildAlias([Parameter(Mandatory=1)][string]$Path, [string[]]$Name) {
	trap {*Die $_ 5}
	$d = switch -regex ($Path) {
		^\*$ {Split-Path (Resolve-MSBuild)}
		^\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.3.9'}

function *IsIB {
	$_.InvocationInfo.ScriptName -match '[\\/]Invoke-Build\.ps1$'
}

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 = ${*}.Prm1
		Prm2 = $(
			$r = @{}
			foreach($_ in ${*}.Prm2.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
	})
}

function *Synopsis($I, $H) {
	$f = $I.ScriptName
	if (!($d = $H[$f])) {
		$H[$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]}
	}
}

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

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 -Value ${*}.All[$args[0]] -Option Constant
	${private:*p} = $args[1] + '/' + $Task.Name
	${*}.Task = $Task

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

	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
	}

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

			Write-Build 11 "Task ${*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: Task ${*p}: $_" $_)
		}
		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 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 ($BuildFile = $MyInvocation.ScriptName) {
		$ErrorActionPreference = 'Stop'
		*SL ($BuildRoot = if ($Task) {*Path $Task} else {Split-Path $BuildFile})
	}
	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 (!${*p1}) {
	${*p1} = @{}
	foreach($_ in $PSBoundParameters.Keys) {
		if (${*r}.ContainsKey($_)) {
			${*p1}[$_] = $PSBoundParameters[$_]
		}
	}
}

if (${private:*0} = $PSCmdlet.SessionState.PSVariable.Get('*')) {
	${*0} = if (${*0}.Description -eq 'IB') {${*0}.Value}
}
New-Variable * -Description IB ([PSCustomObject]@{
	Tasks = [System.Collections.Generic.List[object]]@()
	Errors = [System.Collections.Generic.List[object]]@()
	Warnings = [System.Collections.Generic.List[object]]@()
	Redefined = [System.Collections.Generic.List[object]]@()
	All = ${private:*a} = [System.Collections.Specialized.OrderedDictionary]([System.StringComparer]::OrdinalIgnoreCase)
	Prm1 = $_ = ${*p1}
	Prm2 = ${*r}
	Checkpoint = ${*Checkpoint}
	Started = [DateTime]::Now
	Elapsed = $null
	Error = $null
	Task = $null
	EnterBuild = $null
	ExitBuild = $null
	EnterTask = $null
	ExitTask = $null
	EnterJob = $null
	ExitJob = $null
	Export = $null
	Import = $null
})
if (${private:*?} = $BuildTask -eq '??' -or $BuildTask -eq '?') {
	$WhatIf = $true
}
if ($Result) {
	if ($Result -is [string]) {
		New-Variable -Force -Scope 1 $Result ${*}
	}
	else {
		$Result.Value = ${*}
	}
}
${private:*Safe} = $Safe
${private:*Summary} = $Summary
Remove-Variable Task, File, Checkpoint, Result, Safe, Summary, Resume

${private:*b} = 1
${*r} = 0
try {
	if ($BuildTask -eq '**') {
		${*b} = 0
		foreach($_ in $BuildFile) {
			Invoke-Build @('*'; $BuildTask -ne '**') $_.FullName -Safe:${*Safe}
		}
		${*r} = 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}

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

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

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

	if ($BuildTask -eq '*') {
		*Check ${*a}.Keys
		${**} = @{}
		foreach($_ in ${*a}.Values) {
			foreach($_ in $_.Jobs) {
				if ($_ -is [string]) {
					${**}[$_] = 1
				}
			}
		}
		$BuildTask = foreach($_ in ${*a}.Keys) {if (!${**}[$_]) {$_}}
	}
	else {
		if (!$BuildTask -or '.' -eq $BuildTask) {
			$BuildTask = if (${*a}['.']) {'.'} else {${*a}.Item(0).Name}
		}
		*Check $BuildTask
	}

	Write-Build 11 "Build $($BuildTask -join ', ') $BuildFile"
	foreach($_ in ${*}.Redefined) {
		Write-Build 8 "Redefined task '$($_.Name)'."
	}

	${*b} = 0
	try {
		. *Run ${*}.EnterBuild
		if (${*cp}) {
			foreach($_ in ${*cp}.Done) {
				${*a}[$_].Elapsed = [TimeSpan]::Zero
			}
			foreach($_ in ${*cp}.Prm2.GetEnumerator()) {
				Set-Variable $_.Key $_.Value
			}
			. *Run ${*}.Import ${*cp}.User
		}
		foreach($_ in $BuildTask) {
			*Task $_ ''
		}
		if (${*Checkpoint}) {
			[System.IO.File]::Delete(${*Checkpoint})
		}
	}
	finally {
		${*}.Task = $null
		. *Run ${*}.ExitBuild
	}
	${*r} = 1
	exit 0
}
catch {
	${*r} = 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 (*IsIB) {$PSCmdlet.ThrowTerminatingError($_)}
		throw
	}
}
finally {
	*SL ${*cd}
	if (${*r} -and !${*?}) {
		$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 (*IsIB) {$_} else {*Error $_ $_})"
				}
			}
		}
		if ($w = ${*}.Warnings) {
			foreach($_ in $w) {
				"WARNING: $($_.Message)$(if ($_.Task) {" Task: $($_.Task.Name)."}) File: $($_.File)."
			}
		}
		if (${*0}) {
			${*0}.Tasks.AddRange($t)
			${*0}.Errors.AddRange($e)
			${*0}.Warnings.AddRange($w)
		}
		$c, $m = if (${*b}) {12, "Build ABORTED $BuildFile"}
		elseif (${*r} -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.3.9\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.3.9\InvokeBuild.psd1
@{
	ModuleVersion = '3.3.9'
	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'
	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.3.9\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.3.9\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.3.9\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.3.9</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-05-20T11:21:43+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">5</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">5/20/2017 11:21:43 AM +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">5/20/2017 11:21:43 AM +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.3.9</S>
          </En>
          <En>
            <S N="Key">downloadCount</S>
            <S N="Value">2589</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-05-20T16:05:55Z</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">28648</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.3.9</S>
    </MS>
  </Obj>
</Objs>
tools\InvokeBuild\3.3.9\README.htm
 
tools\InvokeBuild\3.3.9\Release-Notes.htm
 
tools\InvokeBuild\3.3.9\Resolve-MSBuild.ps1

<#PSScriptInfo
.VERSION 1.1.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.

	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.

.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-MSBuild15VSSetup {
	if (Get-Module VSSetup -ListAvailable) {
		Import-Module VSSetup
		if ($vsInstances = Get-VSSetupInstance) {
			$vs = @($vsInstances | Select-VSSetupInstance -Version 15.0 -Require Microsoft.Component.MSBuild)
			if ($vs) {
				return Join-Path ($vs[0].InstallationPath) MSBuild\15.0\Bin\MSBuild.exe
			}
			$vs = @($vsInstances | Select-VSSetupInstance -Version 15.0 -Product Microsoft.VisualStudio.Product.BuildTools)
			if ($vs) {
				return Join-Path ($vs[0].InstallationPath) MSBuild\15.0\Bin\MSBuild.exe
			}
		}
	}
}

function Get-MSBuild15Guess {
	if (!($root = ${env:ProgramFiles(x86)})) {$root = $env:ProgramFiles}
	if (Test-Path -LiteralPath "$root\Microsoft Visual Studio\2017") {
		$rp = @(Resolve-Path "$root\Microsoft Visual Studio\2017\*\MSBuild\15.0\Bin\MSBuild.exe" -ErrorAction 0)
		if ($rp) {
			$rp[-1].ProviderPath
		}
	}
}

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

function Get-MSBuildOldLatest {
	$rp = @(Get-ChildItem HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions | Sort-Object {[Version]$_.PSChildName})
	if ($rp) {
		Join-Path ($rp[-1].GetValue('MSBuildToolsPath')) MSBuild.exe
	}
}

function Get-MSBuildOldVersion($Version) {
	$rp = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$Version", 'MSBuildToolsPath', '')
	if ($rp) {
		Join-Path $rp MSBuild.exe
	}
}

$ErrorActionPreference = 1
try {
	$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) {
			return $path
		}
	}
	elseif ($vRequired -lt $v15) {
		if ($path = Get-MSBuildOldVersion $Version) {
			return $path
		}
	}
	elseif ($vRequired -eq $vMax) {
		if ($path = Get-MSBuild15) {
			return $path
		}
		if ($path = Get-MSBuildOldLatest) {
			return $path
		}
	}

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

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.10.6 30 Tuesday, March 5, 2024 Approved
Invoke-Build 5.10.5 315 Saturday, December 16, 2023 Approved
Invoke-Build 5.10.4 805 Tuesday, May 16, 2023 Approved
Invoke-Build 5.10.3 333 Friday, March 10, 2023 Approved
Invoke-Build 5.10.2 108 Thursday, February 9, 2023 Approved
Invoke-Build 5.10.1 412 Tuesday, October 25, 2022 Approved
Invoke-Build 5.10.0 113 Saturday, October 22, 2022 Approved
Invoke-Build 5.9.12 794 Saturday, September 17, 2022 Approved
Invoke-Build 5.9.11 583 Sunday, August 21, 2022 Approved
Invoke-Build 5.9.10 1678 Tuesday, April 12, 2022 Approved
Invoke-Build 5.9.9.0 595 Thursday, March 10, 2022 Approved
Invoke-Build 5.9.8 123 Monday, March 7, 2022 Approved
Invoke-Build 5.9.7 385 Thursday, February 10, 2022 Approved
Invoke-Build 5.9.6 150 Saturday, February 5, 2022 Approved
Invoke-Build 5.9.5 90 Friday, February 4, 2022 Approved
Invoke-Build 5.9.4 119 Wednesday, February 2, 2022 Approved
Invoke-Build 5.9.3 115 Saturday, January 29, 2022 Approved
Invoke-Build 5.9.2 80 Friday, January 28, 2022 Approved
Invoke-Build 5.9.1 92 Thursday, January 27, 2022 Approved
Invoke-Build 5.9.0 230 Monday, January 17, 2022 Approved
Invoke-Build 5.8.8 260 Sunday, January 2, 2022 Approved
Invoke-Build 5.8.7 227 Monday, December 13, 2021 Approved
Invoke-Build 5.8.6 293 Thursday, November 25, 2021 Approved
Invoke-Build 5.8.5 335 Wednesday, November 10, 2021 Approved
Invoke-Build 5.8.4 1066 Sunday, August 15, 2021 Approved
Invoke-Build 5.8.3 77 Saturday, August 14, 2021 Approved
Invoke-Build 5.8.1 176 Sunday, July 18, 2021 Approved
Invoke-Build 5.8.0 982 Friday, April 16, 2021 Approved
Invoke-Build 5.7.3 287 Saturday, March 27, 2021 Approved
Invoke-Build 5.7.2 479 Sunday, March 7, 2021 Approved
Invoke-Build 5.7.1 202 Saturday, February 27, 2021 Approved
Invoke-Build 5.7.0 239 Saturday, February 20, 2021 Approved
Invoke-Build 5.6.5 907 Monday, January 11, 2021 Approved
Invoke-Build 5.6.4 234 Thursday, December 17, 2020 Approved
Invoke-Build 5.6.3 501 Monday, November 23, 2020 Approved
Invoke-Build 5.6.2 592 Friday, September 11, 2020 Approved
Invoke-Build 5.6.1 216 Friday, August 7, 2020 Approved
Invoke-Build 5.6.0 696 Thursday, May 21, 2020 Approved
Invoke-Build 5.5.11 269 Tuesday, April 28, 2020 Approved
Invoke-Build 5.5.9 242 Wednesday, April 8, 2020 Approved
Invoke-Build 5.5.8 352 Tuesday, March 24, 2020 Approved
Invoke-Build 5.5.7 320 Friday, February 7, 2020 Approved
Invoke-Build 5.5.6 209 Monday, December 16, 2019 Approved
Invoke-Build 5.5.5 217 Thursday, October 17, 2019 Approved
Invoke-Build 5.5.3 247 Friday, August 30, 2019 Approved
Invoke-Build 5.5.2 228 Wednesday, June 12, 2019 Approved
Invoke-Build 5.5.1 242 Wednesday, April 10, 2019 Approved
Invoke-Build 5.5.0 217 Thursday, April 4, 2019 Approved
Invoke-Build 5.4.6 175 Thursday, March 28, 2019 Approved
Invoke-Build 5.4.5 241 Wednesday, March 6, 2019 Approved
Invoke-Build 5.4.4 216 Monday, February 25, 2019 Approved
Invoke-Build 5.4.3 229 Friday, February 15, 2019 Approved
Invoke-Build 5.4.2 639 Saturday, December 8, 2018 Approved
Invoke-Build 5.4.1 668 Thursday, April 12, 2018 Approved
Invoke-Build 5.4.0 329 Tuesday, April 3, 2018 Approved
Invoke-Build 5.3.0 323 Saturday, March 24, 2018 Approved
Invoke-Build 5.2.1 312 Tuesday, March 20, 2018 Approved
Invoke-Build 5.2.0 337 Tuesday, February 27, 2018 Approved
Invoke-Build 5.1.1 315 Thursday, February 15, 2018 Approved
Invoke-Build 5.1.0 301 Thursday, February 8, 2018 Approved
Invoke-Build 5.0.1 356 Tuesday, January 16, 2018 Approved
Invoke-Build 5.0.0 337 Tuesday, January 2, 2018 Approved
Invoke-Build 4.2.0 320 Wednesday, December 20, 2017 Approved
Invoke-Build 4.1.2 377 Thursday, December 7, 2017 Approved
Invoke-Build 4.1.1 336 Monday, December 4, 2017 Approved
Invoke-Build 4.1.0 319 Tuesday, November 28, 2017 Approved
Invoke-Build 4.0.2 358 Sunday, November 26, 2017 Approved
Invoke-Build 4.0.1 325 Thursday, November 23, 2017 Approved
Invoke-Build 4.0.0 355 Wednesday, November 15, 2017 Approved
Invoke-Build 3.7.2 366 Tuesday, November 7, 2017 Approved
Invoke-Build 3.7.1 383 Sunday, October 29, 2017 Approved
Invoke-Build 3.6.5.20170830 449 Wednesday, August 30, 2017 Approved
Invoke-Build 3.6.4 426 Saturday, July 29, 2017 Approved
Invoke-Build 3.6.3 331 Thursday, July 27, 2017 Approved
Invoke-Build 3.6.2 351 Friday, July 21, 2017 Approved
Invoke-Build 3.6.1 355 Saturday, July 15, 2017 Approved
Invoke-Build 3.6.0 362 Saturday, July 8, 2017 Approved
Invoke-Build 3.5.3 382 Friday, June 30, 2017 Approved
Invoke-Build 3.5.2 359 Tuesday, June 27, 2017 Approved
Invoke-Build 3.5.1 400 Thursday, June 22, 2017 Approved
Invoke-Build 3.5.0 339 Saturday, June 17, 2017 Approved
Invoke-Build 3.4.0 369 Thursday, June 8, 2017 Approved
Invoke-Build 3.3.11 366 Friday, June 2, 2017 Approved
Invoke-Build 3.3.10 382 Friday, May 26, 2017 Approved
Invoke-Build 3.3.9 343 Saturday, May 20, 2017 Approved
Invoke-Build 3.3.8 434 Friday, May 12, 2017 Approved
Invoke-Build 3.3.7 343 Tuesday, May 9, 2017 Approved
Invoke-Build 3.3.6 336 Sunday, April 30, 2017 Approved
Invoke-Build 3.3.5 379 Monday, April 24, 2017 Approved
Invoke-Build 3.3.4 370 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