Downloads:
34,898
Downloads of v 5.2.1:
333
Last Update:
20 Mar 2018
Package Maintainer(s):
Software Author(s):
- Roman Kuzmin
Tags:
build powershell module cross-platform foss- Software Specific:
- Software Site
- Software Source
- Software License
- Software Docs
- Software Issues
- Package Specific:
- Package Source
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Invoke-Build
This is not the latest version of Invoke-Build available.
- 1
- 2
- 3
5.2.1 | Updated: 20 Mar 2018
- Software Specific:
- Software Site
- Software Source
- Software License
- Software Docs
- Software Issues
- Package Specific:
- Package Source
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
34,898
Downloads of v 5.2.1:
333
Maintainer(s):
Software Author(s):
- Roman Kuzmin
Invoke-Build 5.2.1
This is not the latest version of Invoke-Build available.
Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by Roman Kuzmin. The inclusion of Roman Kuzmin trademark(s), if any, upon this webpage is solely to identify Roman Kuzmin goods or services and not for commercial purposes.
- 1
- 2
- 3
All Checks are Passing
3 Passing Tests
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:
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
Option 1: Cached Package (Unreliable, Requires Internet - Same As Community)-
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
-
Open Source
-
Download the package:
Download - Follow manual internalization instructions
-
-
Package Internalizer (C4B)
-
Run: (additional options)
choco download invoke-build --internalize --version=5.2.1 --source=https://community.chocolatey.org/api/v2/
-
For package and dependencies run:
choco push --source="'INTERNAL REPO URL'"
- Automate package internalization
-
Run: (additional options)
3. Copy Your Script
choco upgrade invoke-build -y --source="'INTERNAL REPO URL'" --version="'5.2.1'" [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="'5.2.1'"
$exitCode = $LASTEXITCODE
Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
- name: Install invoke-build
win_chocolatey:
name: invoke-build
version: '5.2.1'
source: INTERNAL REPO URL
state: present
See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.
chocolatey_package 'invoke-build' do
action :install
source 'INTERNAL REPO URL'
version '5.2.1'
end
See docs at https://docs.chef.io/resource_chocolatey_package.html.
cChocoPackageInstaller invoke-build
{
Name = "invoke-build"
Version = "5.2.1"
Source = "INTERNAL REPO URL"
}
Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.
package { 'invoke-build':
ensure => '5.2.1',
provider => 'chocolatey',
source => 'INTERNAL REPO URL',
}
Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.
4. If applicable - Chocolatey configuration/installation
See infrastructure management matrix for Chocolatey configuration elements and examples.
This package was approved as a trusted package on 20 Mar 2018.
Invoke-Build is a build and test automation tool which invokes tasks defined in PowerShell v2.0+ scripts. It is similar to psake but arguably easier to use and more powerful. It is complete, bug free, well covered by tests.
Features
- Incremental tasks with effectively processed inputs and outputs.
- Persistent builds which can be resumed after interruptions.
- Parallel builds in separate workspaces with common stats.
- Batch invocation of tests composed as tasks.
- Ability to define new classes of tasks.
Invoke-Build can invoke the current task from a build script being composed in ISE and VSCode, see Invoke-TaskFromISE.ps1 and Invoke-TaskFromVSCode.ps1.
Invoke-Build can be used as the task runner in VSCode with tasks maintained in a PowerShell build script instead of tasks.json, see New-VSCodeTask.ps1.
Invoke-Build v3.0.1 is cross-platform with PowerShell v6.0.0-alpha.
Notes
- This package includes
Invoke-TaskFromISE
,Invoke-TaskFromVSCode
,New-VSCodeTask
andInvoke-Build.ArgumentCompleters
supportive scripts. To setup launch profile in VSCode for build.ps1 files, use the following script path inlaunch.json
:"script": "${env:ChocolateyInstall}/lib/invoke-build/tools/Invoke-TaskFromVSCode.ps1"
- Its recommended to include the following in your PowerShell
$PROFILE
:sal ib Invoke-Build & $env:ChocolateyInstall\lib\invoke-build\tools\Invoke-Build.ArgumentCompleters.ps1
$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"
<#PSScriptInfo
.VERSION 1.0.2
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.GUID 78b68f80-80c5-4cc1-9ded-e2ae165a9cbd
.TAGS Invoke-Build, TabExpansion2, Register-ArgumentCompleter
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>
<#
.Synopsis
Argument completers for Invoke-Build parameters.
.Description
The script registers Invoke-Build completers for parameters Task and File.
Completers can be used with:
* PowerShell v5 native Register-ArgumentCompleter
Simply invoke Invoke-Build.ArgumentCompleters.ps1, e.g. in a profile.
* TabExpansionPlusPlus https://github.com/lzybkr/TabExpansionPlusPlus
Put Invoke-Build.ArgumentCompleters.ps1 to the TabExpansionPlusPlus module
directory in order to be loaded automatically. Or invoke it after importing
the module, e.g. in a profile.
* TabExpansion2.ps1 https://www.powershellgallery.com/packages/TabExpansion2
Put Invoke-Build.ArgumentCompleters.ps1 to the path in order to be loaded
automatically on the first completion. Or invoke after TabExpansion2.ps1,
e.g. in a profile.
#>
Register-ArgumentCompleter -CommandName Invoke-Build.ps1 -ParameterName Task -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $boundParameters)
(Invoke-Build -Task ?? -File ($boundParameters['File'])).Keys -like "$wordToComplete*" | .{process{
New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_
}}
}
Register-ArgumentCompleter -CommandName Invoke-Build.ps1 -ParameterName File -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $boundParameters)
Get-ChildItem -Directory -Name "$wordToComplete*" | .{process{
New-Object System.Management.Automation.CompletionResult $_, $_, 'ProviderContainer', $_
}}
if (!($boundParameters['Task'] -eq '**')) {
Get-ChildItem -File -Name "$wordToComplete*.ps1" | .{process{
New-Object System.Management.Automation.CompletionResult $_, $_, 'Command', $_
}}
}
}
<#PSScriptInfo
.VERSION 1.0.2
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.TAGS Invoke, Task, Invoke-Build, ISE
.GUID 713b2e68-8b62-40f5-99cb-07c6952abca6
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>
<#
.Synopsis
Invokes the current task from PowerShell ISE by Invoke-Build.ps1
.Description
This script invokes the current task from the build script being edited in
PowerShell ISE. It is invoked either in ISE or in PowerShell console.
Invoke-Build.ps1 is searched in the directory of Invoke-TaskFromISE.ps1
and then in the path.
The current task is the task at the caret line or above. If none is found
then the default task is invoked. The script is saved if it is modified.
If the build fails when the task is invoked in ISE and the error location
is in the same build script then the caret is moved to the error position.
This script may be called directly from the console pane. But it is easier
to associate it with key shortcuts. For example, in order to invoke it by
Ctrl+Shift+T and Ctrl+Shift+B open the ISE profile:
C:\Users\...\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
and add menu commands and shortcuts:
# Invoke task in ISE by Invoke-Build.ps1
$null = $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(
'Invoke Task in ISE', {Invoke-TaskFromISE.ps1}, 'Ctrl+Shift+T')
# Invoke task in console by Invoke-Build.ps1
$null = $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(
'Invoke Task in Console', {Invoke-TaskFromISE.ps1 -Console}, 'Ctrl+Shift+B')
These commands assume that Invoke-TaskFromISE.ps1 is in the path.
If this is not the case then specify the full script path there.
.Parameter Console
Tells to invoke the current task in a new PowerShell console.
#>
param(
[Parameter()]
[switch]$Console
)
$ErrorActionPreference = 'Stop'
$private:ib = "$(Split-Path $MyInvocation.MyCommand.Path)\Invoke-Build.ps1"
if (!(Test-Path -LiteralPath $ib)) {
$ib = 'Invoke-Build'
}
$private:_Console = $Console
Remove-Variable Console
$private:file = $psISE.CurrentFile
if (!$file) {Write-Error "There is not a current file."}
if ($file.IsUntitled) {Write-Error "Cannot invoke for Untitled files, please save the file."}
$private:path = $file.FullPath
if ($path -notlike '*.ps1') {Write-Error "The current file must be '*.ps1'."}
if (!$file.IsSaved) {
$file.Save()
}
$private:task = '.'
$private:editor = $file.Editor
$private:line = $editor.CaretLine
foreach($private:t in (& $ib ?? $path).Values) {
if ($t.InvocationInfo.ScriptName -ne $path) {continue}
if ($t.InvocationInfo.ScriptLineNumber -gt $line) {break}
$task = $t.Name
}
if ($_Console) {
Start-Process PowerShell.exe ("-NoExit -NoProfile -ExecutionPolicy Bypass & '{0}' '{1}' '{2}'" -f @(
$ib.Replace("'", "''")
$task.Replace("'", "''").Replace('"', '\"')
$path.Replace("'", "''")
))
return
}
try {
& $ib $task $path
}
catch {
$ii = $_.InvocationInfo
if ($ii.ScriptName -eq $path) {
$editor.SetCaretPosition($ii.ScriptLineNumber, $ii.OffsetInLine)
}
throw
}
<#PSScriptInfo
.VERSION 1.0.6
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.TAGS Invoke-Build, Task, VSCode
.GUID 1dcf7c94-b68d-4fb7-9e2b-886889b6c42e
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>
<#
.Synopsis
Invokes the current Invoke-Build task from VSCode
.Description
This script invokes the current task from the build script in VSCode.
Requires:
- Invoke-Build
- VSCode PowerShell
How to use:
https://github.com/nightroman/Invoke-Build/wiki/Invoke-Task-from-VSCode
.Parameter Console
Tells to invoke the task in an external console.
.Link
https://github.com/nightroman/Invoke-Build/wiki/Invoke-Task-from-VSCode
#>
param(
[Parameter()]
[switch]$Console
)
try {
$ErrorActionPreference = 'Stop'
$private:file = $null
try {
$private:context = $psEditor.GetEditorContext()
$file = $context.CurrentFile
}
catch {}
if (!$file) {throw 'Cannot get the current file.'}
# save if modified, #118
if ($psEditor.EditorServicesVersion -ge [version]'1.6') {
$file.Save()
}
$private:_Console = $Console
Remove-Variable Console
$private:path = $file.Path
if ($path -notlike '*.ps1') {throw "The current file must be '*.ps1'."}
$private:task = '.'
$private:line = $context.CursorPosition.Line
foreach($private:t in (Invoke-Build ?? $path).Values) {
if ($t.InvocationInfo.ScriptName -ne $path) {continue}
if ($t.InvocationInfo.ScriptLineNumber -gt $line) {break}
$task = $t.Name
}
if ($_Console) {
$command = "Invoke-Build '$($task.Replace("'", "''"))' '$($path.Replace("'", "''"))'"
$encoded = [Convert]::ToBase64String(([System.Text.Encoding]::Unicode.GetBytes($command)))
Start-Process powershell.exe "-NoExit -NoProfile -ExecutionPolicy Bypass -EncodedCommand $encoded"
}
else {
Invoke-Build $task $path
}
} catch {if ($_.InvocationInfo.ScriptName -like '*Invoke-TaskFromVSCode.ps1') {$PSCmdlet.ThrowTerminatingError($_)} throw}
TOPIC
about_InvokeBuild
SHORT DESCRIPTION
Build and test automation in PowerShell
LONG DESCRIPTION
The module provides the following commands:
Invoke-Build
The alias of Invoke-Build.ps1
It invokes build scripts, this is the build engine.
Build-Checkpoint
The alias of Build-Checkpoint.ps1
It invokes persistent builds using the engine.
Build-Parallel
The alias of Build-Parallel.ps1
It invokes parallel builds using the engine.
Import the installed module:
Import-Module InvokeBuild
Or import from the specified location:
Import-Module <path>\InvokeBuild.psd1
Get help for the engine:
help <path>\Invoke-Build.ps1 -full
Get help for build commands:
. <path>\Invoke-Build.ps1
help task -full
help exec -full
...
The package contains the build engine with a few helpers, all you need
for running build scripts. There are various related tools, see README.
<#
Copyright 2011-2018 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 InvokeBuild-Help.xml
param(
[Parameter(Position=0, Mandatory=1)][string]$Checkpoint,
[Parameter(Position=1)][hashtable]$Build,
[switch]$Resume
)
try {
$ErrorActionPreference = 'Stop'
$Checkpoint = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($Checkpoint)
$Build = if ($Build) {@{} + $Build} else {@{}}
if ($Build['WhatIf']) {throw 'WhatIf is not supported.'}
${*checkpoint} = @{
Checkpoint = $Checkpoint
Result = $Build['Result']
Data = $null
}
$Build.Remove('Result')
if ($Resume) {
if (![System.IO.File]::Exists($Checkpoint)) {throw "Missing checkpoint '$Checkpoint'."}
${*checkpoint}.Data = try {Import-Clixml $Checkpoint} catch {throw 'Invalid checkpoint file?'}
foreach($_ in @($Build.Keys)) {
if ($_ -ne 'Safe' -and $_ -ne 'Summary') {
$Build.Remove($_)
}
}
$Build.Task = ${*checkpoint}.Data.Task
$Build.File = ${*checkpoint}.Data.File
$Build = $Build + ${*checkpoint}.Data.Prm1
}
${*checkpoint}.XBuild = {
if (${*checkpoint}.Data) {
foreach($_ in ${*checkpoint}.Data.Done) {
${*}.All[$_].Elapsed = [TimeSpan]::Zero
}
foreach($_ in ${*checkpoint}.Data.Prm2.GetEnumerator()) {
Set-Variable $_.Key $_.Value -Scope Script
}
if ($_ = ${*}.Data['Checkpoint.Import']) {
. *Run $_ ${*checkpoint}.Data.User
}
}
}
${*checkpoint}.XTask = {
Export-Clixml ${*checkpoint}.Checkpoint -InputObject @{
User = *Run ${*}.Data['Checkpoint.Export']
Task = $BuildTask
File = $BuildFile
Prm1 = ${*}.SP
Prm2 = $(
$r = @{}
foreach($_ in ${*}.DP.Keys) {
$r[$_] = Get-Variable -Name $_ -Scope Script -ValueOnly
}
$r
)
Done = @(foreach($t in ${*}.All.Values) {if ($t.Elapsed) {$t.Name}})
}
}
$_ = $Build
Remove-Variable Checkpoint, Build, Resume
Set-Alias Invoke-Build (Join-Path (Split-Path $MyInvocation.MyCommand.Path) Invoke-Build.ps1)
Invoke-Build @_ -Result ${*checkpoint}
if (!${*checkpoint}.Value.Error) {
[System.IO.File]::Delete(${*checkpoint}.Checkpoint)
}
}
catch {
if ($_.InvocationInfo.ScriptName -notmatch '\b(Invoke-Build|Build-Checkpoint)\.ps1$') {throw}
$PSCmdlet.ThrowTerminatingError($_)
}
finally {
if ($r = ${*checkpoint}.Result) {
if ($r -is [string]) {
New-Variable $r ${*checkpoint}.Value -Scope 1 -Force
}
else {
$r.Value = ${*checkpoint}.Value
}
}
}
<#
Copyright 2011-2018 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 InvokeBuild-Help.xml
param(
[Parameter(Position=0)][hashtable[]]$Build,
$Result,
[int]$Timeout=[int]::MaxValue,
[int]$MaximumBuilds=[Environment]::ProcessorCount,
[switch]$FailHard
)
# info, result
$info = [PSCustomObject]@{
Tasks = [System.Collections.Generic.List[object]]@()
Errors = [System.Collections.Generic.List[object]]@()
Warnings = [System.Collections.Generic.List[object]]@()
Started = [DateTime]::Now
Elapsed = $null
}
if ($Result) {
if ($Result -is [string]) {
New-Variable $Result $info -Scope 1 -Force
}
else {
$Result.Value = $info
}
}
# no builds
if (!$Build) {return}
# get and source the engine
$ib = Join-Path (Split-Path $MyInvocation.MyCommand.Path) Invoke-Build.ps1
try {. $ib} catch {$PSCmdlet.ThrowTerminatingError($_)}
$ErrorActionPreference = 'Stop'
### make works, check scripts
$works = @()
for ($1 = 0; $1 -lt $Build.Count) {
$b = @{} + $Build[$1]
$Build[$1++] = $b
if ($file = $b['File']) {
if (![System.IO.File]::Exists(($file = *Path $file))) {*Die "Missing script '$file'." 13}
}
elseif (!($file = Get-BuildFile (*Path))) {
*Die "Missing default script in build $1." 5
}
$b.Result = @{}
$b.File = $file
$b.Safe = $true
$work = @{}
$works += $work
$work.Build = $b
$work.Done = $false
$work.Error1 = $null
$work.Error2 = $null
$work.Title = "($1/$($Build.Count)) $file"
}
### prepare logs and make shells
foreach($work in $works) {
$b = $work.Build
if ($log = $b['Log']) {
$work.Temp = $false
$b.Remove('Log')
[System.IO.File]::Delete(($log = *Path $log))
}
else {
$work.Temp = $true
$log = [System.IO.Path]::GetTempFileName()
}
$work.Log = $log
$work.PS = [PowerShell]::Create().AddCommand($ib).AddParameters($b).AddCommand('Out-File').AddParameter('FilePath', $log).AddParameter('Encoding', 'UTF8')
}
function Write-Log($work) {
$file = $work.Log
if ($work.Temp) {
try {
$read = [System.IO.File]::OpenText($file)
while($null -ne ($_ = $read.ReadLine())) {$_}
$read.Close()
}
catch {
Write-Warning $_
}
[System.IO.File]::Delete($file)
}
else {
"Log: $file"
}
}
### main
if ($MaximumBuilds -lt 1) {*Die "MaximumBuilds should be a positive number." 5}
$MaximumBuilds = [math]::Min($MaximumBuilds, $Build.Count)
$stage = [System.Collections.Generic.List[object]]@()
$iWork = 0
$abort = ''
$failures = @()
$stopwatch = [Diagnostics.Stopwatch]::StartNew()
try {
for() {
### stage next work(s), BeginInvoke
while($stage.Count -lt $MaximumBuilds -and $iWork -lt $works.Count) {
$work = $works[$iWork++]
$stage.Add($work)
Write-Build Cyan "Start $($work.Title)"
$work.Job = $work.PS.BeginInvoke()
}
if (!$stage) {break}
### wait for any staged
$waits = New-Object System.Collections.Generic.List[System.Threading.WaitHandle]
foreach($work in $stage) {$waits.Add($work.Job.AsyncWaitHandle)}
$time = $Timeout - $stopwatch.ElapsedMilliseconds
$index = [System.Threading.WaitHandle]::WaitAny($waits.ToArray(), $time, $true)
if ($index -eq [System.Threading.WaitHandle]::WaitTimeout) {
$abort = 'Build timed out.'
break
}
### unstage done, EndInvoke
$work = $stage[$index]
$stage.RemoveAt($index)
$work.Done = $true
try {
$work.PS.EndInvoke($work.Job)
$work.Error2 = $work.Build.Result.Value.Error
}
catch {
$work.Error1 = "Invalid build arguments or script. Error: $_"
}
### abort?
if (($work.Error1 -or $work.Error2) -and $FailHard) {
$abort = "Aborted by $($work.Title)"
break
}
}
### finish works
foreach($work in $works) {
Write-Build Cyan "Build $($work.Title):"
### get error and dispose
$runtime = $false
$_ = try {
if ($work.Done) {
if ($work.Error1) {
$work.Error1
}
else {
$runtime = $true
$r = $work.Build.Result.Value
$info.Tasks.AddRange($r.Tasks)
$info.Errors.AddRange($r.Errors)
$info.Warnings.AddRange($r.Warnings)
$r.Error
}
}
else {
$work.PS.Stop()
$abort
}
}
catch {
$_
}
finally {
$work.PS.Dispose()
}
### log
Write-Log $work
### result
if ($_) {
Write-Build Cyan "Build $($work.Title) FAILED."
$_ = if ($_ -is [System.Management.Automation.ErrorRecord] -and $runtime) {*Msg $_ $_} else {"$_"}
Write-Build Red "ERROR: $_"
$failures += @{
File = $work.Title
Error = $_
}
}
else {
Write-Build Cyan "Build $($work.Title) succeeded."
}
}
### fail?
if ($failures) {
*Die ($(
"Failed builds:"
foreach($_ in $failures) {
"Build: $($_.File)"
"ERROR: $($_.Error)"
}
) -join [Environment]::NewLine)
}
}
finally {
$errors = $info.Errors.Count
$warnings = $info.Warnings.Count
$info.Elapsed = [DateTime]::Now - $info.Started
if (($up = $PSCmdlet.SessionState.PSVariable.Get('*')) -and ($up = if ($up.Description -eq 'IB') {$up.Value})) {
$up.Tasks.AddRange($info.Tasks)
$up.Errors.AddRange($info.Errors)
$up.Warnings.AddRange($info.Warnings)
}
$color, $text = if ($failures) {12, 'Builds FAILED'}
elseif ($errors) {14, 'Builds completed with errors'}
elseif ($warnings) {14, 'Builds succeeded with warnings'}
else {10, 'Builds succeeded'}
Write-Build $color @"
Tasks: $($info.Tasks.Count) tasks, $errors errors, $warnings warnings
$text. $($Build.Count) builds, $($failures.Count) failed $($info.Elapsed)
"@
}
:: ib.cmd - Invoke-Build helper for cmd.exe
:: It must be in the same directory as Invoke-Build.ps1
@echo off
if "%1"=="?" goto list
if "%1"=="/?" goto help
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0Invoke-Build.ps1' %*"
exit /B %errorlevel%
:list
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0Invoke-Build.ps1' %* | Format-Table -AutoSize"
exit /B 0
:help
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "help -Full '%~dp0Invoke-Build.ps1'"
exit /B 0
<#
Copyright 2011-2018 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 InvokeBuild-Help.xml
param(
[Parameter(Position=0)][string[]]$Task,
[Parameter(Position=1)]$File,
$Result,
[switch]$Safe,
[switch]$Summary,
[switch]$WhatIf
)
dynamicparam {
function *Path($P) {
$PSCmdlet.GetUnresolvedProviderPathFromPSPath($P)
}
function *Die($M, $C=0) {
$PSCmdlet.ThrowTerminatingError((New-Object System.Management.Automation.ErrorRecord ([Exception]"$M"), $null, $C, $null))
}
function Get-BuildFile($Path) {
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)
}
if ($MyInvocation.InvocationName -eq '.') {return}
trap {*Die $_ 5}
New-Variable * -Description IB ([PSCustomObject]@{
All = [System.Collections.Specialized.OrderedDictionary]([System.StringComparer]::OrdinalIgnoreCase)
Tasks = [System.Collections.Generic.List[object]]@()
Errors = [System.Collections.Generic.List[object]]@()
Warnings = [System.Collections.Generic.List[object]]@()
Redefined = @()
Doubles = @()
Started = [DateTime]::Now
Elapsed = $null
Error = 'Invalid arguments.'
Task = $null
File = $BuildFile = $PSBoundParameters['File']
Safe = $PSBoundParameters['Safe']
Summary = $PSBoundParameters['Summary']
CD = *Path
DP = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
SP = @{}
P = $(if ($_ = $PSCmdlet.SessionState.PSVariable.Get('*')) {if ($_.Description -eq 'IB') {$_.Value}})
A = 1
B = 0
Q = 0
H = @{}
EnterBuild = $null
ExitBuild = $null
EnterTask = $null
ExitTask = $null
EnterJob = $null
ExitJob = $null
Header = {Write-Build 11 "Task $($args[0])"}
Data = @{}
XBuild = $null
XTask = $null
})
if ($_ = $PSBoundParameters['Result']) {
if ($_ -is [string]) {
New-Variable $_ ${*} -Scope 1 -Force
}
elseif ($_ -is [hashtable]) {
${*}.XBuild = $_['XBuild']
${*}.XTask = $_['XTask']
$_.Value = ${*}
}
else {throw 'Invalid parameter Result.'}
}
$BuildTask = $PSBoundParameters['Task']
if ($BuildFile -is [scriptblock]) {
$BuildFile = $BuildFile.File
return
}
if ($BuildTask -eq '**') {
if (![System.IO.Directory]::Exists(($_ = *Path $BuildFile))) {throw "Missing directory '$_'."}
$BuildFile = @(Get-ChildItem -LiteralPath $_ -Filter *.test.ps1 -Recurse)
return
}
if ($BuildFile) {
if (![System.IO.File]::Exists(($BuildFile = *Path $BuildFile))) {throw "Missing script '$BuildFile'."}
}
elseif (!($BuildFile = Get-BuildFile ${*}.CD)) {
throw 'Missing default script.'
}
${*}.File = $BuildFile
if (!($_ = (Get-Command $BuildFile -ErrorAction 1).Parameters)) {
& $BuildFile
throw 'Invalid script.'
}
if ($_.Count) {&{
$c = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'ErrorVariable', 'WarningVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable', 'InformationAction', 'InformationVariable'
$r = 'Task', 'File', 'Result', 'Safe', 'Summary', 'WhatIf'
foreach($p in $_.Values) {
if ($c -notcontains ($_ = $p.Name)) {
if ($r -contains $_) {throw "Script uses reserved parameter '$_'."}
${*}.DP.Add($_, (New-Object System.Management.Automation.RuntimeDefinedParameter $_, $p.ParameterType, $p.Attributes))
foreach($a in $p.Attributes) {if ($a -is [System.Management.Automation.ParameterAttribute]) {$a.Position = 0x80000000}}
}
}
${*}.DP
}}
} end {
#.ExternalHelp InvokeBuild-Help.xml
function Add-BuildTask(
[Parameter(Position=0, Mandatory=1)][string]$Name,
[Parameter(Position=1)]$Jobs,
[string[]]$After,
[string[]]$Before,
$If=$true,
$Inputs,
$Outputs,
$Data,
$Done,
$Source=$MyInvocation,
[switch]$Partial
)
{
trap {*Die "Task '$Name': $_" 5}
if ($Jobs -is [hashtable]) {
if ($PSBoundParameters.Count -ne 2) {throw 'Invalid parameters.'}
Add-BuildTask $Name @Jobs -Source:$Source
return
}
if ($Name[0] -eq '?') {throw 'Invalid task name.'}
if ($_ = ${*}.All[$Name]) {${*}.Redefined += $_}
${*}.All[$Name] = [PSCustomObject]@{
Name = $Name
Error = $null
Started = $null
Elapsed = $null
Jobs = $1 = [System.Collections.Generic.List[object]]@()
After = $After
Before = $Before
If = $If
Inputs = $Inputs
Outputs = $Outputs
Data = $Data
Done = $Done
Partial = $Partial
InvocationInfo = $Source
}
if (!$Jobs) {return}
$1.AddRange(@($Jobs))
$2 = @()
foreach($j in $1) {
$r, $null = *Job $j
if ($2 -contains $r) {${*}.Doubles += ,($Name, $r)}
$2 += $r
}
}
#.ExternalHelp InvokeBuild-Help.xml
function Assert-Build([Parameter()]$Condition, [string]$Message) {
if (!$Condition) {
*Die "Assertion failed.$(if ($Message) {" $Message"})" 7
}
}
#.ExternalHelp InvokeBuild-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 InvokeBuild-Help.xml
function Get-BuildError([Parameter(Mandatory=1)][string]$Task) {
if (!($_ = ${*}.All[$Task])) {
*Die "Missing task '$Task'." 5
}
$_.Error
}
#.ExternalHelp InvokeBuild-Help.xml
function Get-BuildProperty([Parameter(Mandatory=1)][string]$Name, $Value) {
${*n} = $Name
${*v} = $Value
Remove-Variable Name, Value
if (($null -ne ($_ = $PSCmdlet.GetVariableValue(${*n})) -and '' -ne $_) -or ($_ = [Environment]::GetEnvironmentVariable(${*n}))) {return $_}
if ($null -eq ${*v}) {*Die "Missing property '${*n}'." 13}
${*v}
}
#.ExternalHelp InvokeBuild-Help.xml
function Get-BuildSynopsis([Parameter(Mandatory=1)]$Task, $Hash=${*}.H) {
$f = ($I = $Task.InvocationInfo).ScriptName
if (!($d = $Hash[$f])) {
$Hash[$f] = $d = @{T = Get-Content -LiteralPath $f; C = @{}}
foreach($_ in [System.Management.Automation.PSParser]::Tokenize($d.T, [ref]$null)) {
if ($_.Type -eq 15) {$d.C[$_.EndLine] = $_.Content}
}
}
for($n = $I.ScriptLineNumber; --$n -ge 1) {
if ($c = $d.C[$n]) {if ($c -match '(?m)^\s*#*\s*Synopsis\s*:(.*)') {return $Matches[1].Trim()}}
elseif ($d.T[$n - 1].Trim()) {break}
}
}
#.ExternalHelp InvokeBuild-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 InvokeBuild-Help.xml
function Test-BuildAsset([Parameter(Position=0)][string[]]$Variable, [string[]]$Environment, [string[]]$Property) {
Remove-Variable Variable, Environment, Property
if ($_ = $PSBoundParameters['Variable']) {foreach($_ in $_) {
if ($null -eq ($$ = $PSCmdlet.GetVariableValue($_)) -or '' -eq $$) {*Die "Missing variable '$_'." 13}
}}
if ($_ = $PSBoundParameters['Environment']) {foreach($_ in $_) {
if (!([Environment]::GetEnvironmentVariable($_))) {*Die "Missing environment variable '$_'." 13}
}}
if ($_ = $PSBoundParameters['Property']) {foreach($_ in $_) {
if ('' -eq (Get-BuildProperty $_ '')) {*Die "Missing property '$_'." 13}
}}
}
#.ExternalHelp InvokeBuild-Help.xml
function Use-BuildAlias([Parameter(Mandatory=1)][string]$Path, [string[]]$Name) {
trap {*Die $_ 5}
$d = switch -regex ($Path) {
'^\*|^\d+\.' {Split-Path (Resolve-MSBuild $_)}
^Framework {"$env:windir\Microsoft.NET\$_"}
default {*Path $_}
}
if (![System.IO.Directory]::Exists($d)) {throw "Cannot resolve '$Path'."}
foreach($_ in $Name) {
Set-Alias $_ (Join-Path $d $_) -Scope 1
}
}
#.ExternalHelp InvokeBuild-Help.xml
function Write-Build([ConsoleColor]$Color, [string]$Text) {
$i = $Host.UI.RawUI
$_ = $i.ForegroundColor
try {
$i.ForegroundColor = $Color
$Text
}
finally {
$i.ForegroundColor = $_
}
}
if ($env:APPVEYOR) {
function Write-Build([ConsoleColor]$Color, [string]$Text) {Write-Host $Text -ForegroundColor $Color}
}
else {
try {$null = Write-Build 0} catch {function Write-Build($Color, [string]$Text) {$Text}}
}
function *My {
$_.InvocationInfo.ScriptName -eq $MyInvocation.ScriptName
}
function *SL($P=$BuildRoot) {
Set-Location -LiteralPath $P -ErrorAction 1
}
function *Fin([Parameter()]$M, $C=0) {
*Die $M $C
}
function *Run($_) {
if ($_) {
*SL
. $_ @args
}
}
function *At($I) {
$I.InvocationInfo.PositionMessage.Trim()
}
function *Msg($M, $I) {
@"
$M
$(*At $I)
"@
}
function *Job($J) {
if ($J -is [string]) {if ($J[0] -eq '?') {$J.Substring(1), 1} else {$J}}
elseif ($J -is [scriptblock]) {$J}
else {*Fin 'Invalid job.' 5}
}
function *Unsafe($N, $J) {
if ($J -contains $N) {return 1}
foreach($_ in $J) {
$r, $null = *Job $_
if ($r -ne $N -and ($t = ${*}.All[$r]) -and $t.If -and (*Unsafe $N $t.Jobs)) {
return 1
}
}
}
function *Amend($X, $J, $B) {
$n = $X.Name
foreach($_ in $J) {
$r, $s = *Job $_
if (!($t = ${*}.All[$r])) {*Fin (*Msg "Task '$n': Missing task '$r'." $X) 5}
$j = $t.Jobs
$i = $j.Count
if ($B) {
for($k = -1; ++$k -lt $i -and $j[$k] -is [string]) {}
$i = $k
}
$j.Insert($i, $(if ($s) {"?$n"} else {$n}))
}
}
function *Check($J, $T, $P=@()) {
foreach($_ in $J) { if ($_ -is [string]) {
$_, $null = *Job $_
if (!($r = ${*}.All[$_])) {
$_ = "Missing task '$_'."
*Fin $(if ($T) {*Msg "Task '$($T.Name)': $_" $T} else {$_}) 5
}
if ($P -contains $r) {
*Fin (*Msg "Task '$($T.Name)': Cyclic reference to '$_'." $T) 5
}
*Check $r.Jobs $r ($P + $r)
}}
}
filter *Help {
$r = 1 | Select-Object Name, Jobs, Synopsis
$r.Name = $_.Name
$r.Jobs = foreach($j in $_.Jobs) {if ($j -is [string]) {$j} else {'{}'}}
$r.Synopsis = Get-BuildSynopsis $_
$r
}
function *Root($A) {
*Check $A.Keys
$h = @{}
foreach($_ in $A.Values) {foreach($_ in $_.Jobs) {
if ($_ -is [string]) {
$_, $null = *Job $_
$h[$_] = 1
}
}}
foreach($_ in $A.Keys) {if (!$h[$_]) {$_}}
}
function *Err($T) {
${*}.Errors.Add([PSCustomObject]@{Error = $_; File = $BuildFile; Task = $T})
Write-Build 12 "ERROR: $(if (*My) {$_} else {*Msg $_ $_})"
if ($T) {$T.Error = $_}
}
function *IO {
if ((${private:*i} = $Task.Inputs) -is [scriptblock]) {
*SL
${*i} = @(& ${*i})
}
*SL
${private:*p} = [System.Collections.Generic.List[object]]@()
${*i} = foreach($_ in ${*i}) {
if ($_ -isnot [System.IO.FileInfo]) {$_ = [System.IO.FileInfo](*Path $_)}
if (!$_.Exists) {*Fin "Missing input '$_'." 13}
${*p}.Add($_.FullName)
$_
}
if (!${*p}) {return 2, 'Skipping empty input.'}
${private:*o} = $Task.Outputs
if ($Task.Partial) {
${*o} = @(
if (${*o} -is [scriptblock]) {
${*p} | & ${*o}
*SL
}
else {
${*o}
}
)
if (${*p}.Count -ne ${*o}.Count) {*Fin "Different Inputs/Outputs counts: $(${*p}.Count)/$(${*o}.Count)." 6}
$k = -1
$Task.Inputs = $i = [System.Collections.Generic.List[object]]@()
$Task.Outputs = $o = [System.Collections.Generic.List[object]]@()
foreach($_ in ${*i}) {
$f = *Path ($p = ${*o}[++$k])
if (![System.IO.File]::Exists($f) -or $_.LastWriteTime -gt [System.IO.File]::GetLastWriteTime($f)) {
$i.Add(${*p}[$k])
$o.Add($p)
}
}
if ($i) {return $null, "Out-of-date outputs: $($o.Count)/$(${*p}.Count)."}
}
else {
if (${*o} -is [scriptblock]) {
$Task.Outputs = ${*o} = ${*p} | & ${*o}
*SL
}
if (!${*o}) {*Fin 'Outputs must not be empty.' 5}
$Task.Inputs = ${*p}
$m = (${*i} | .{process{$_.LastWriteTime.Ticks}} | Measure-Object -Maximum).Maximum
foreach($_ in ${*o}) {
$p = *Path $_
if (![System.IO.File]::Exists($p)) {return $null, "Missing output '$_'."}
if ($m -gt [System.IO.File]::GetLastWriteTime($p).Ticks) {return $null, "Out-of-date output '$_'."}
}
}
2, 'Skipping up-to-date output.'
}
function *Task {
${private:*p} = "$($args[1])/$($args[0])"
${private:*n}, ${private:*s} = *Job $args[0]
New-Variable Task (${*}.Task = ${*}.All[${*n}]) -Option Constant
if ($Task.Elapsed) {
Write-Build 8 "Done ${*p}"
return
}
$Task.Started = [DateTime]::Now
if (${*}.XTask) {& ${*}.XTask}
if ((${private:*x} = $Task.If) -is [scriptblock]) {
*SL
try {
${*x} = & ${*x}
}
catch {
*Err $Task
${*}.Tasks.Add($Task)
Write-Build 14 (*At $Task)
$Task.Elapsed = [TimeSpan]::Zero
throw
}
}
if (!${*x}) {
Write-Build 8 "Task ${*p} skipped."
return
}
${private:*i} = , [int]($null -ne $Task.Inputs)
try {
. *Run ${*}.EnterTask
foreach(${private:*j} in $Task.Jobs) {
if (${*j} -is [string]) {
*Task ${*j} ${*p}
continue
}
& ${*}.Header ${*p}
if (1 -eq ${*i}[0]) {
try {
${*i} = *IO
}
catch {
*Err $Task
throw
}
Write-Build 8 ${*i}[1]
}
if (${*i}[0]) {
continue
}
try {
. *Run ${*}.EnterJob
*SL
if (0 -eq ${*i}[0]) {
& ${*j}
}
else {
$Inputs = $Task.Inputs
$Outputs = $Task.Outputs
if ($Task.Partial) {
${*x} = 0
$Inputs | .{process{
$2 = $Outputs[${*x}++]
$_
}} | & ${*j}
}
else {
$Inputs | & ${*j}
}
}
}
catch {
*Err $Task
throw
}
finally {
. *Run ${*}.ExitJob
}
}
}
catch {
$Task.Error = $_
if (!${*s} -or (*Unsafe ${*n} $BuildTask)) {throw}
}
finally {
$Task.Elapsed = [DateTime]::Now - $Task.Started
${*}.Tasks.Add($Task)
if ($Task.Error) {
Write-Build 14 (*At $Task)
}
else {
Write-Build 11 "Done ${*p} $($Task.Elapsed)"
}
*Run $Task.Done
. *Run ${*}.ExitTask
}
}
Set-Alias assert Assert-Build
Set-Alias equals Assert-BuildEquals
Set-Alias error Get-BuildError
Set-Alias exec Invoke-BuildExec
Set-Alias property Get-BuildProperty
Set-Alias requires Test-BuildAsset
Set-Alias task Add-BuildTask
Set-Alias use Use-BuildAlias
Set-Alias Invoke-Build ($_ = $MyInvocation.MyCommand.Path)
$_ = Split-Path $_
Set-Alias Show-TaskHelp (Join-Path $_ Show-TaskHelp.ps1)
Set-Alias Build-Parallel (Join-Path $_ Build-Parallel.ps1)
Set-Alias Resolve-MSBuild (Join-Path $_ Resolve-MSBuild.ps1)
if ($MyInvocation.InvocationName -eq '.') {
Remove-Variable Task, File, Result, Safe, Summary, WhatIf
return
}
function Write-Warning([Parameter()]$Message) {
$PSCmdlet.WriteWarning($Message)
${*}.Warnings.Add([PSCustomObject]@{Message = $Message; File = $BuildFile; Task = ${*}.Task})
}
$ErrorActionPreference = 'Stop'
foreach($_ in $PSBoundParameters.Keys) {
if (${*}.DP.ContainsKey($_)) {
${*}.SP[$_] = $PSBoundParameters[$_]
}
}
if (${*}.Q = $BuildTask -eq '?' -or $BuildTask -eq '??') {
$WhatIf = $true
}
Remove-Variable Task, File, Result, Safe, Summary
${*}.Error = $null
try {
if ($BuildTask -eq '**') {
${*}.A = 0
foreach($_ in $BuildFile) {
Invoke-Build * $_.FullName -Safe:${*}.Safe
}
${*}.B = 1
exit
}
function Enter-Build([Parameter()][scriptblock]$Script) {${*}.EnterBuild = $Script}
function Exit-Build([Parameter()][scriptblock]$Script) {${*}.ExitBuild = $Script}
function Enter-BuildTask([Parameter()][scriptblock]$Script) {${*}.EnterTask = $Script}
function Exit-BuildTask([Parameter()][scriptblock]$Script) {${*}.ExitTask = $Script}
function Enter-BuildJob([Parameter()][scriptblock]$Script) {${*}.EnterJob = $Script}
function Exit-BuildJob([Parameter()][scriptblock]$Script) {${*}.ExitJob = $Script}
function Set-BuildHeader([Parameter()][scriptblock]$Script) {${*}.Header = $Script}
function Set-BuildData([Parameter()]$Key, $Value) {${*}.Data[$Key] = $Value}
*SL ($BuildRoot = if ($BuildFile) {Split-Path $BuildFile} else {${*}.CD})
$_ = ${*}.SP
${private:**} = @(. ${*}.File @_)
foreach($_ in ${**}) {
Write-Warning "Unexpected output: $_."
if ($_ -is [scriptblock]) {*Fin "Dangling scriptblock at $($_.File):$($_.StartPosition.StartLine)" 6}
}
if (!(${**} = ${*}.All).Count) {*Fin "No tasks in '$BuildFile'." 6}
foreach($_ in ${**}.Values) {
if ($_.Before) {*Amend $_ $_.Before 1}
}
foreach($_ in ${**}.Values) {
if ($_.After) {*Amend $_ $_.After}
}
if (${*}.Q) {
*Check ${**}.Keys
if ($BuildTask -eq '?') {
${**}.Values | *Help
}
else {
${**}
}
exit
}
if ($BuildTask -eq '*') {
$BuildTask = *Root ${**}
}
else {
if (!$BuildTask -or '.' -eq $BuildTask) {
$BuildTask = if (${**}['.']) {'.'} else {${**}.Item(0).Name}
}
*Check $BuildTask
}
if ($WhatIf) {
Show-TaskHelp
exit
}
New-Variable BuildRoot (*Path $BuildRoot) -Option Constant -Force
if (![System.IO.Directory]::Exists($BuildRoot)) {*Fin "Missing build root '$BuildRoot'." 13}
Write-Build 11 "Build $($BuildTask -join ', ') $BuildFile"
foreach($_ in ${*}.Redefined) {
Write-Build 8 "Redefined task '$($_.Name)'."
}
foreach($_ in ${*}.Doubles) {
if (${*}.All[$_[1]].If -isnot [scriptblock]) {
Write-Warning "Task '$($_[0])' always skips '$($_[1])'."
}
}
${*}.A = 0
try {
. *Run ${*}.EnterBuild
if (${*}.XBuild) {. ${*}.XBuild}
foreach($_ in $BuildTask) {
*Task $_ ''
}
}
finally {
${*}.Task = $null
. *Run ${*}.ExitBuild
}
${*}.B = 1
exit
}
catch {
${*}.B = 2
${*}.Error = $_
if (!${*}.Errors) {*Err}
if ($_.FullyQualifiedErrorId -eq 'PositionalParameterNotFound,Add-BuildTask') {
Write-Warning 'Check task parameters: Name and comma separated Jobs.'
}
if (${*}.Safe) {
exit
}
elseif (*My) {
$PSCmdlet.ThrowTerminatingError($_)
}
throw
}
finally {
*SL ${*}.CD
if (${*}.B -and !${*}.Q) {
$t = ${*}.Tasks
$e = ${*}.Errors
if (${*}.Summary) {
Write-Build 11 'Build summary:'
foreach($_ in $t) {
'{0,-16} {1} - {2}:{3}' -f $_.Elapsed, $_.Name, $_.InvocationInfo.ScriptName, $_.InvocationInfo.ScriptLineNumber
if ($_ = $_.Error) {
Write-Build 12 "ERROR: $(if (*My) {$_} else {*Msg $_ $_})"
}
}
}
if ($w = ${*}.Warnings) {
foreach($_ in $w) {
"WARNING: $($_.Message)$(if ($_.Task) {" Task: $($_.Task.Name)."}) File: $($_.File)."
}
}
if ($_ = ${*}.P) {
$_.Tasks.AddRange($t)
$_.Errors.AddRange($e)
$_.Warnings.AddRange($w)
}
$c, $m = if (${*}.A) {12, "Build ABORTED $BuildFile"}
elseif (${*}.B -eq 2) {12, 'Build FAILED'}
elseif ($e) {14, 'Build completed with errors'}
elseif ($w) {14, 'Build succeeded with warnings'}
else {10, 'Build succeeded'}
Write-Build $c "$m. $($t.Count) tasks, $($e.Count) errors, $($w.Count) warnings $((${*}.Elapsed = [DateTime]::Now - ${*}.Started))"
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<helpItems xmlns="http://msh" schema="maml">
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Invoke-Build.ps1</command:name>
<maml:description>
<maml:para>Invoke-Build - Build Automation in PowerShell</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>The command invokes so called tasks defined in a PowerShell script.
Let's call this process build and a script with tasks build script.
A build script defines parameters, variables, and one or more tasks.
Any code is invoked with the current location set to $BuildRoot,
the script directory. $ErrorActionPreference is set to 'Stop'.
SCRIPT PARAMETERS
Build scripts define parameters as usual using the param() block.
On calling, specify them for Invoke-Build as if they are its own.
Known issue #4. Specify script switches after Task and File.
The following parameter names are reserved for the engine:
Task, File, Result, Safe, Summary, WhatIf
COMMANDS AND HELP
The following commands are available for build scripts:
task (Add-BuildTask)
exec (Invoke-BuildExec)
assert (Assert-Build)
equals (Assert-BuildEquals)
property (Get-BuildProperty)
requires (Test-BuildAsset)
use (Use-BuildAlias)
error (Get-BuildError)
Get-BuildSynopsis
Resolve-MSBuild
Write-Build
Write-Warning [1]
[1] Write-Warning is redefined internally in order to count warnings in
a build script and nested scripts. Warnings in modules are not counted.
To get commands help, dot-source Invoke-Build and then call help:
PS> . Invoke-Build
PS> help task -full
SPECIAL ALIASES
Invoke-Build
Build-Parallel
These aliases are for the scripts Invoke-Build.ps1 and Build-Parallel.ps1.
Use them for calling nested builds, i.e. omit script extensions and paths.
PUBLIC VARIABLES
$WhatIf - WhatIf mode, Invoke-Build parameter
$BuildRoot - build script location, by default
$BuildFile - build script path
$BuildTask - initial tasks
$Task - current task
$BuildRoot may be changed by scripts on loading in order to set a custom
build root directory. Other variables should not be changed.
$Task is available for script blocks defined by task parameters If, Inputs,
Outputs, and Jobs and by blocks Enter|Exit-BuildTask, Enter|Exit-BuildJob,
Set-BuildHeader.
$Task properties:
- Name - [string], task name
- Jobs - [object[]], task jobs
- Started - [DateTime], task start time
And in Exit-BuildTask:
- Error - task error or null
- Elapsed - [TimeSpan], task duration
BUILD BLOCKS
Scripts may define special script blocks. They are invoked:
Enter-Build {} - before the first task
Exit-Build {} - after the last task
Enter-BuildTask {} - before each task
Exit-BuildTask {} - after each task
Enter-BuildJob {} - before each task action
Exit-BuildJob {} - after each task action
Set-BuildHeader {param($Path)} - to write task headers
Blocks are not called on WhatIf.
Nested builds do not inherit parent blocks.
If Enter-X is called then Exit-X is also called, even on failures.
Enter-Build and Exit-Build are invoked in the script scope. Enter-Build is
suitable for initialization and it can output text unlike the build script.
Enter-BuildTask, Exit-BuildTask, Enter-BuildJob, and Exit-BuildJob are
invoked in the same scope, the parent of task action blocks.
PRIVATE STUFF
Function and variable names starting with '*' are reserved for the engine.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-Build.ps1</maml:name>
<command:parameter required="false" position="1" >
<maml:name>Task</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>File</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Safe</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Summary</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>WhatIf</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="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 '.' then the task '.' is invoked if it exists, otherwise
the first added task is invoked.
Names with wildcard characters are reserved for special cases.
SAFE REFERENCES
If a task 'X' is referenced as '?X' then it is allowed to fail without
breaking the build, i.e. other tasks specified after X will be invoked.
SPECIAL TASKS
? - Tells to list tasks with brief information and check for errors.
Task synopses are defined in preceding comments as # Synopsis: ...
?? - Tells to collect and get all tasks as an ordered dictionary.
It can be used by external tools for analysis, completion, etc.
Tasks ? and ?? set $WhatIf to true. Properly designed build scripts
should not perform anything significant if $WhatIf is set to true.
* - Tells to invoke all tasks, for example when tasks are tests.
** - Invokes * for all files *.test.ps1 found recursively in the
current directory or a directory specified by the parameter File.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>File</maml:name>
<maml:description>
<maml:para>A build script which adds tasks by the command 'task' (Add-BuildTask).
If it is not specified then Invoke-Build looks for *.build.ps1 files in
the current location. A single file is used as the script. If there are
more files then .build.ps1 is used if it exists, otherwise build fails.
If the build file is not found then a script defined by the environment
variable InvokeBuildGetFile is called with the path as an argument. For
this location it may return the full path of a special build script.
If the file is still not found then parent directories are searched.
INLINE SCRIPT
'File' is a script block which is normally used in order to assemble a
build on the fly without creating and using an extra build script file.
$BuildFile is the calling script (or null, e.g. in jobs).
The default $BuildRoot is its directory (or the current location).
Script parameters, parallel, and persistent builds are not supported.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<maml:description>
<maml:para>Tells to make the build result. Normally it is the name of a variable
created in the calling scope. Or it is a hashtable which entry Value
contains the result.
Result properties:
All - all available tasks
Error - a terminating build error
Tasks - invoked tasks including nested
Errors - error objects including nested
Warnings - warning objects including nested
Redefined - list of original redefined tasks
Tasks is a list of objects:
Name - task name
Jobs - task jobs
Error - task error
Started - start time
Elapsed - task duration
InvocationInfo - task location (.ScriptName, .ScriptLineNumber)
Errors is a list of objects:
Error - original error
File - current $BuildFile
Task - current $Task or null for other errors
Warnings is a list of objects:
Message - warning message
File - current $BuildFile
Task - current $Task or null for other warnings
Do not change these data and do not use not documented members.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Safe</maml:name>
<maml:description>
<maml:para>Tells to catch a build failure, store an error as the property Error of
Result and return quietly. A caller should use Result and check Error.
Some exceptions are possible even in the safe mode. They show serious
errors, not build failures. For example, a build script is missing.
When Safe is used together with the special task ** (invoke *.test.ps1)
then task failures stop current test scripts, not the whole testing.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Summary</maml:name>
<maml:description>
<maml:para>Tells to show summary information after the build. It includes task
durations, names, locations, and error messages.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>WhatIf</maml:name>
<maml:description>
<maml:para>Tells to show tasks and jobs to be invoked and some analysis of used
parameters and environment variables. See Show-TaskHelp for details.
If a script does anything but adding tasks then it should check for
$WhatIf and skip the real actions in order to support WhatIf calls.
Alternatively, use the Enter-Build block for pre-build actions.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Text</maml:name>
</dev:type>
<maml:description>
<maml:para>Build log which includes task records and engine messages, warnings,
errors, and output from build script tasks and special blocks.
The script itself should not output anything. Unexpected script output
causes warnings, in the future it may be treated as an error.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>## How to call Invoke-Build in order to deal with build failures.
## Use one of the below techniques or you may miss some failures.
## (1/2) If you do not want to catch errors and just want the calling
## script to stop on build failures then
$ErrorActionPreference = 'Stop'
Invoke-Build ...
## (2/2) If you want to catch build errors and proceed further depending
## on them then use try/catch, $ErrorActionPreference does not matter:
try {
Invoke-Build ...
# Build completed
}
catch {
# Build FAILED, $_ is the error
}</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Invoke tasks Build and Test from the default script with parameters.
# The script defines parameters Output and WarningLevel by param().
Invoke-Build Build, Test -Output log.txt -WarningLevel 4</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title>
<dev:code># Show tasks in the default script and the specified script
Invoke-Build ?
Invoke-Build ? Project.build.ps1
# Custom formatting is possible, too
Invoke-Build ? | Format-Table -AutoSize
Invoke-Build ? | Format-List Name, Synopsis</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 4 --------------------------</maml:title>
<dev:code># Get task names without invoking for listing, TabExpansion, etc.
$all = Invoke-Build ??
$all.Keys</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 5 --------------------------</maml:title>
<dev:code># Invoke all in Test1.test.ps1 and all in Tests\...\*.test.ps1
Invoke-Build * Test1.test.ps1
Invoke-Build ** Tests</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 6 --------------------------</maml:title>
<dev:code># How to use build results, e.g. for summary
try {
# Invoke build and get the variable Result
Invoke-Build -Result Result
}
finally {
# Show build error
"Build error: $(if ($Result.Error) {$Result.Error} else {'None'})"
# Show task summary
$Result.Tasks | Format-Table Elapsed, Name, Error -AutoSize
}</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Wiki</maml:linkText>
<maml:uri>https://github.com/nightroman/Invoke-Build/wiki</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Project</maml:linkText>
<maml:uri>https://github.com/nightroman/Invoke-Build</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>task (Add-BuildTask)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>exec (Invoke-BuildExec)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>assert (Assert-Build)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>equals (Assert-BuildEquals)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>property (Get-BuildProperty)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>requires (Test-BuildAsset)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>use (Use-BuildAlias)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>error (Get-BuildError)</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-BuildSynopsis</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Resolve-MSBuild</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Write-Build</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Build-Checkpoint</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Build-Parallel</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Add-BuildTask</command:name>
<maml:description>
<maml:para>(task) Defines and adds a task.</maml:para>
</maml:description>
<command:verb>Add</command:verb>
<command:noun>BuildTask</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias 'task'. It is normally used in the build script scope
but it can be called from another script or function. Build scripts should
have at least one task.
This command is all that build scripts really need. Tasks are main build
blocks. Other build commands are helpers, scripts do not have to use them.
In addition to task parameters, you may use task help comments, synopses,
preceding task definitions:
# Synopsis: ...
task ...
Synopses are used in task help information returned by the command
Invoke-Build ?
To get a task synopsis during a build, use Get-BuildSynopsis.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Add-BuildTask</maml:name>
<command:parameter required="true" position="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">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Before</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Data</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Done</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>If</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Inputs</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Outputs</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Source</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Partial</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="1" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>The task name. Wildcard characters are deprecated and "?" must not be
the first character. Duplicated names are allowed, each added task
overrides previously added with the same name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Jobs</maml:name>
<maml:description>
<maml:para>Specifies one or more task jobs or a hashtable with actual parameters.
Jobs are other task references and own actions, script blocks. Any
number of jobs is allowed. Jobs are invoked in the specified order.
Valid jobs are:
[string] - an existing task name, normal reference
[string] "?Name" - safe reference to a task allowed to fail
[scriptblock] - action, a script block invoked for this task
Special value:
[hashtable] which contains the actual task parameters in addition
to the task name. This task definition is more convenient with
complex parameters, often typical for incremental tasks.
Example:
task Name @{
Inputs = {...}
Outputs = {...}
Partial = $true
Jobs = {
process {...}
}
}</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>After</maml:name>
<maml:description>
<maml:para>Tells to add this task to the end of jobs of the specified tasks.
Altered tasks are defined as normal references (TaskName) or safe
references (?TaskName). In the latter case this inserted task may
fail without stopping a build.
Parameters After and Before are used in order to alter task jobs
in special cases when direct changes in task source code are not
suitable. Use Jobs in order to define relations in usual cases.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Before</maml:name>
<maml:description>
<maml:para>Tells to insert this task to jobs of the specified tasks.
It is inserted before the first action or added to the end.
See After for details.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Data</maml:name>
<maml:description>
<maml:para>Any object attached to the task. It is not used by the engine.
When the task is invoked this object is available as $Task.Data.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Done</maml:name>
<maml:description>
<maml:para>Specifies the command or a script block which is invoked after the
task. Custom handlers should check for $Task.Error if it matters.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>If</maml:name>
<maml:description>
<maml:para>Specifies the optional condition to be evaluated. If the condition
evaluates to false then the task is not invoked. The condition is
defined in one of two ways depending on the requirements.
Using standard Boolean notation (parenthesis) the condition is checked
once when the task is defined. A use case for this notation might be
evaluating a script parameter or another sort of global condition.
Example:
task Task1 -If ($Param1 -eq ...) {...}
task Task2 -If ($PSVersionTable.PSVersion.Major -ge 5) {...}
Using script block notation (curly braces) the condition is evaluated
on task invocation. If a task is referenced by several tasks then the
condition is evaluated each time until it gets true and the task is
invoked. The script block notation is normally used for a condition
that may be defined or changed during the build or just expensive.
Example:
task SomeTask -If {...} {...}</maml:para>
</maml:description>
<dev:defaultValue>$true</dev:defaultValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Inputs</maml:name>
<maml:description>
<maml:para>Specifies the input items, tells to process the task as incremental,
and requires the parameter Outputs with the optional switch Partial.
Inputs are file items or paths or a script block which gets them.
Outputs are file paths or a script block which gets them.
A script block is invoked with input paths piped to it.
Automatic variables for incremental task actions:
$Inputs - full input paths, array of strings
$Outputs - result of the evaluated Outputs
With the switch Partial the task is processed as partial incremental.
There must be one-to-one correspondence between Inputs and Outputs.
Partial task actions often contain "process {}" blocks.
Two more automatic variables are available for them:
$_ - full path of an input item
$2 - corresponding output path
See also wiki topics about incremental tasks:
https://github.com/nightroman/Invoke-Build/wiki</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Outputs</maml:name>
<maml:description>
<maml:para>Specifies the output paths of the incremental task, either directly on
task creation or as a script block invoked with the task. It is used
together with Inputs. See Inputs for details.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Partial</maml:name>
<maml:description>
<maml:para>Tells to process the incremental task as partial incremental.
It is used with Inputs and Outputs. See Inputs for details.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Source</maml:name>
<maml:description>
<maml:para>Specifies the task source. It is used by wrapper functions in order to
provide the actual source for location messages and synopsis comments.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Dummy task with no jobs
task Task1
# Alias of another task
task Task2 Task1
# Combination of tasks
task Task3 Task1, Task2
# Simple action task
task Task4 {
# action
}
# Typical complex task: referenced task(s) and one own action
task Task5 Task1, Task2, {
# action after referenced tasks
}
# Possible complex task: actions and tasks in any required order
task Task6 {
# action before Task1
},
Task1, {
# action after Task1 and before Task2
},
Task2</dev:code>
<dev:remarks>
<maml:para>This example shows various possible combinations of task jobs.</maml:para>
<maml:para></maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Synopsis: Complex task with parameters as a hashtable.
task TestAndAnalyse @{
If = !$SkipAnalyse
Inputs = {
Get-ChildItem . -Recurse -Include *.ps1, *.psm1
}
Outputs = {
'Analyser.log'
}
Jobs = 'Test', {
Invoke-ScriptAnalyzer . > Analyser.log
}
}
# Synopsis: Simple task with usual parameters.
task Test -If (!$SkipTest) {
Invoke-Pester
}</dev:code>
<dev:remarks>
<maml:para>Tasks with complex parameters are often difficult to compose in a readable
way. In such cases use a hashtable in order to specify task parameters in
addition to the task name. Keys and values correspond to parameter names
and values.</maml:para>
</dev:remarks>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Get-BuildError</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-BuildSynopsis</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:uri>https://github.com/nightroman/Invoke-Build/wiki</maml:uri>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Get-BuildError</command:name>
<maml:description>
<maml:para>(error) Gets the specified task error.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildError</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias 'error'. It is used for a task with a safe reference
'?TaskName' in order to get and analyse its potential error.</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>An error or null if the task has not failed.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Add-BuildTask</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Assert-Build</command:name>
<maml:description>
<maml:para>(assert) Checks for a condition.</maml:para>
</maml:description>
<command:verb>Assert</command:verb>
<command:noun>Build</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias 'assert'. This command checks for a condition and
if it is not true throws an error with the default or specified message.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Assert-Build</maml:name>
<command:parameter required="false" position="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>(equals) Verifies that two specified objects are equal.</maml:para>
</maml:description>
<command:verb>Assert</command:verb>
<command:noun>BuildEquals</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias 'equals'. This command verifies that two specified
objects are equal using [Object]::Equals(). If objects are not equal the
command fails with a message showing object values and types.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Assert-BuildEquals</maml:name>
<command:parameter required="false" position="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>(property) Gets the session or environment variable or the default.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildProperty</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias 'property'. The command returns:
- session variable value if it is not $null or ''
- environment variable if it is not $null or ''
- default value if it is not $null
- error</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildProperty</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Value</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="1" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the session or environment variable name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Value</maml:name>
<maml:description>
<maml:para>Specifies the default value. If it is omitted or null then the variable
must exist with a not empty value. Otherwise an error is thrown.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Object</maml:name>
</dev:type>
<maml:description>
<maml:para>Requested property value.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Inherit an existing value or throw an error
$OutputPath = property OutputPath</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Get an existing value or use the default
$WarningLevel = property WarningLevel 4</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Test-BuildAsset</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Get-BuildSynopsis</command:name>
<maml:description>
<maml:para>Gets the task synopsis.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>BuildSynopsis</command:noun>
</command:details>
<maml:description>
<maml:para>Gets the specified task synopsis if it is available.
Task synopsis is defined in preceding comments as # Synopsis: ...</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-BuildSynopsis</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Task</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Hash</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="1" >
<maml:name>Task</maml:name>
<maml:description>
<maml:para>The task object. During the build, the current task is available as the
automatic variable $Task.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Hash</maml:name>
<maml:description>
<maml:para>A hashtable for caching data. Build scripts do not have to specify it,
it is designed for external tools.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>String</maml:name>
</dev:type>
<maml:description>
<maml:para>Task synopsis line.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Print task path and synopsis
Set-BuildHeader {
param($Path)
Write-Build Cyan "Task $Path : $(Get-BuildSynopsis $Task)"
}
# Synopsis: Show task data useful for headers
task Task1 {
$Task.Name
$Task.InvocationInfo.ScriptName
$Task.InvocationInfo.ScriptLineNumber
}</dev:code>
</command:example>
</command:examples>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Invoke-BuildExec</command:name>
<maml:description>
<maml:para>(exec) Invokes an application and checks $LastExitCode.</maml:para>
</maml:description>
<command:verb>Invoke</command:verb>
<command:noun>BuildExec</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias 'exec'. 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.</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 and may contain the code of another command.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>ExitCode</maml:name>
<maml:description>
<maml:para>Valid exit codes (e.g. 0..3 for robocopy).</maml:para>
</maml:description>
<dev:defaultValue>@(0)</dev:defaultValue>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Objects</maml:name>
</dev:type>
<maml:description>
<maml:para>Output of the specified command.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Call robocopy (0..3 are valid exit codes)
exec { robocopy Source Target /mir } (0..3)</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Use-BuildAlias</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Test-BuildAsset</command:name>
<maml:description>
<maml:para>(requires) Checks for required build assets.</maml:para>
</maml:description>
<command:verb>Test</command:verb>
<command:noun>BuildAsset</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias 'requires'. This command tests the required build
assets. It fails if something is missing or invalid. It is used either
in script code (common assets) or in tasks (individual assets).</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Test-BuildAsset</maml:name>
<command:parameter required="false" position="1" >
<maml:name>Variable</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Environment</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="1" >
<maml:name>Variable</maml:name>
<maml:description>
<maml:para>Specifies session variable names and tells to fail if a variable is
missing or its value is null or an empty string.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Environment</maml:name>
<maml:description>
<maml:para>Specifies environment variable names and tells to fail if a variable is
not defined or its value is an empty string.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<maml:description>
<maml:para>Specifies session or environment variable names and tells to fail if a
variable is missing or its value is null or an empty string. It makes
sense to use `property` later with tested names without defaults.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Get-BuildProperty</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Use-BuildAlias</command:name>
<maml:description>
<maml:para>(use) Sets framework or directory tool aliases.</maml:para>
</maml:description>
<command:verb>Use</command:verb>
<command:noun>BuildAlias</command:noun>
</command:details>
<maml:description>
<maml:para>Scripts use its alias 'use'. Invoke-Build does not change the system path
in order to make framework tools available by names. This is not suitable
for using mixed framework tools (in different tasks, scripts, parallel
builds). Instead, this function is used for setting tool aliases in the
scope where it is called.
This command may be used in the script scope to make aliases for all tasks.
But it can be called from tasks in order to use more task specific tools.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Use-BuildAlias</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Path</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="1" >
<maml:name>Path</maml:name>
<maml:description>
<maml:para>Specifies the tools directory.
If it is * or it starts with digits followed by a dot then the MSBuild
path is resolved using the package script Resolve-MSBuild.ps1. Build
scripts may invoke it directly by the provided alias Resolve-MSBuild.
The optional suffix x86 tells to use 32-bit MSBuild.
If it is like Framework* then it is assumed to be a path relative to
Microsoft.NET in the Windows directory.
Otherwise it is a full or relative literal path of any directory.
Examples: *, 4.0, Framework\v4.0.30319, .\Tools</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="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>Build-Parallel.ps1</command:name>
<maml:description>
<maml:para>Invokes parallel builds by Invoke-Build</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>This script invokes 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>Build-Parallel.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:parameter required="false" position="named" >
<maml:name>FailHard</maml:name>
</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>FailHard</maml:name>
<maml:description>
<maml:para>Tells to abort all builds if any build fails.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>MaximumBuilds</maml:name>
<maml:description>
<maml:para>Maximum number of builds invoked at the same time.</maml:para>
</maml:description>
<dev:defaultValue>Number of processors.</dev:defaultValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<maml:description>
<maml:para>Tells to output build results using a variable. It is either a name of
variable to be created for results or any object with the property
Value to be assigned ([ref], [hashtable]).
Result properties:
Tasks - tasks (*)
Errors - errors (*)
Warnings - warnings (*)
Started - start time
Elapsed - build duration
(*) see: help Invoke-Build -Parameter Result</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Timeout</maml:name>
<maml:description>
<maml:para>Maximum overall build time in milliseconds.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Text</maml:name>
</dev:type>
<maml:description>
<maml:para>Output of invoked builds and other log messages.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>Build-Parallel @(
@{File='Project1.build.ps1'}
@{File='Project2.build.ps1'; Task='MakeHelp'}
@{File='Project2.build.ps1'; Task='Build', 'Test'}
@{File='Project3.build.ps1'; Log='C:\TEMP\Project3.log'}
@{File='Project4.build.ps1'; Configuration='Release'}
)</dev:code>
<dev:remarks>
<maml:para>Five parallel builds are invoked with various combinations of parameters.
Note that it is fine to invoke the same build script more than once if
build flows specified by different tasks do not conflict.</maml:para>
</dev:remarks>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Invoke-Build</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Build-Checkpoint.ps1</command:name>
<maml:description>
<maml:para>Invokes persistent builds with checkpoints.</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>This command invokes the build specified by the hashtable Build so that it
writes checkpoints to the file specified by Checkpoint. If the build fails
then it may be resumed later, use the switch Resume in addition to the
original Checkpoint parameter. The build is resumed at the failed task.
Not every build may be persistent, right away or at all:
- 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.
CUSTOM EXPORT AND IMPORT
By default, the command saves and restores build tasks, script path, and
all parameters declared by the build script, not just specified by Build.
Tip: consider to declare some script variables as artificial parameters
in order to make them persistent.
If this is not enough for saving and restoring the build state then use
custom export and import blocks. The export block is called on writing
checkpoints, i.e. on each task. The import block is called on resuming
once, before the task to be resumed.
The export block is defined as
Set-BuildData Checkpoint.Export {
$script:var1
$script:var2
}
The import block is defined as
Set-BuildData Checkpoint.Import {
param($data)
$var1, $var2 = $data
}
Note that the import block is called in the script scope. In the example,
variables $var1, $var2 are the script variables, you may but do not have
to use the prefix `$script:`. The parameter $data is the data written by
Checkpoint.Export, exported to clixml and then imported from clixml.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Build-Checkpoint.ps1</maml:name>
<command:parameter required="true" position="1" >
<maml:name>Checkpoint</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Build</maml:name>
<command:parameterValue required="true">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Resume</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="1" >
<maml:name>Checkpoint</maml:name>
<maml:description>
<maml:para>Specifies the checkpoint file (clixml). The checkpoint file is removed
after successful builds. If a build fails and it is not going to be
resumed then delete the checkpoint file manually.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>Build</maml:name>
<maml:description>
<maml:para>Specifies the build and script parameters. WhatIf is not supported.
On Resume tasks, script path, and script parameters are ignored.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Resume</maml:name>
<maml:description>
<maml:para>Tells to resume the build from the existing checkpoint file.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Text</maml:name>
</dev:type>
<maml:description>
<maml:para>Output of the invoked build.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Invoke a persistent sequence of steps defined as tasks.
Build-Checkpoint temp.clixml @{Task = '*'; File = 'Steps.build.ps1'}
# Given the above failed, resume at the failed step.
Build-Checkpoint temp.clixml -Resume</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Invoke-Build</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
</helpItems>
@{
ModuleVersion = '5.2.1'
ModuleToProcess = 'InvokeBuild.psm1'
GUID = 'a0319025-5f1f-47f0-ae8d-9c7e151a5aae'
Author = 'Roman Kuzmin'
CompanyName = 'Roman Kuzmin'
Copyright = '(c) 2011-2018 Roman Kuzmin'
Description = 'Build and test automation in PowerShell'
PowerShellVersion = '2.0'
AliasesToExport = 'Invoke-Build', 'Build-Checkpoint', 'Build-Parallel'
PrivateData = @{
PSData = @{
Tags = 'Build', 'Test', 'Automation'
ProjectUri = 'https://github.com/nightroman/Invoke-Build'
LicenseUri = 'http://www.apache.org/licenses/LICENSE-2.0'
IconUri = 'https://raw.githubusercontent.com/nightroman/Invoke-Build/master/ib.png'
ReleaseNotes = 'https://github.com/nightroman/Invoke-Build/blob/master/Release-Notes.md'
}
}
}
Set-Alias -Name Build-Checkpoint -Value (Join-Path $PSScriptRoot Build-Checkpoint.ps1)
Set-Alias -Name Build-Parallel -Value (Join-Path $PSScriptRoot Build-Parallel.ps1)
Set-Alias -Name Invoke-Build -Value (Join-Path $PSScriptRoot Invoke-Build.ps1)
Export-ModuleMember -Alias Build-Checkpoint, Build-Parallel, Invoke-Build
Invoke-Build - Build Automation in PowerShell
Copyright (c) 2011-2018 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.
<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">5.2.1</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-2018 Roman Kuzmin</S>
<DT N="PublishedDate">2018-03-19T20:56:27+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">21</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-2018 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">3/19/2018 8:56:27 PM +00:00</S>
</En>
<En>
<S N="Key">description</S>
<S N="Value">Build and test automation in PowerShell</S>
</En>
<En>
<S N="Key">published</S>
<S N="Value">3/19/2018 8:56:27 PM +00:00</S>
</En>
<En>
<S N="Key">developmentDependency</S>
<S N="Value">False</S>
</En>
<En>
<S N="Key">NormalizedVersion</S>
<S N="Value">5.2.1</S>
</En>
<En>
<S N="Key">downloadCount</S>
<S N="Value">28237</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">2018-03-20T00:41:08Z</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">37384</S>
</En>
<En>
<S N="Key">FileList</S>
<S N="Value">InvokeBuild.nuspec|about_InvokeBuild.help.txt|Build-Checkpoint.ps1|Build-Parallel.ps1|ib.cmd|Invoke-Build.ps1|InvokeBuild-Help.xml|InvokeBuild.psd1|InvokeBuild.psm1|LICENSE.txt|README.htm|Release-Notes.htm|Resolve-MSBuild.ps1|Show-TaskHelp.ps1</S>
</En>
<En>
<S N="Key">requireLicenseAcceptance</S>
<S N="Value">False</S>
</En>
</DCT>
</Obj>
<S N="InstalledLocation">C:\projects\au-packages\invoke-build\tools\InvokeBuild\5.2.1</S>
</MS>
</Obj>
</Objs>
<#PSScriptInfo
.VERSION 1.3.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 for MSBuild 15.0, 14.0, 12.0, 4.0, 3.5, 2.0.
For MSBuild 15.0 the command uses VSSetup module from PSGallery.
If it is not installed then some default locations are checked.
VSSetup module is required for not default installations.
MSBuild 15.0 resolution: the latest version (if requested by -Latest), then
Enterprise, Professional, Community, BuildTools, other products. If this is
not suitable then use VSSetup module and choose differently.
For MSBuild 2.0-14.0 the information is taken from the registry.
.Parameter Version
Specifies the required MSBuild version. If it is omitted, empty, or *
then the command finds and returns the latest installed version path.
The optional suffix x86 tells to use 32-bit MSBuild.
Known versions: 15.0, 14.0, 12.0, 4.0, 3.5, 2.0
.Parameter Latest
Tells to select the latest (minor) version if there are 2+ products
with the same (major) version. For example, 15.0 actually gets 15.x
and Latest tells to choose the version before the product.
.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
#>
[OutputType([string])]
[CmdletBinding()]
param(
[string]$Version,
[switch]$Latest
)
function Get-MSBuild15Path($Bitness) {
if ([System.IntPtr]::Size -eq 4 -or $Bitness -eq 'x86') {
'MSBuild\15.0\Bin\MSBuild.exe'
}
else {
'MSBuild\15.0\Bin\amd64\MSBuild.exe'
}
}
function Get-MSBuild15VSSetup($Bitness, [switch]$Latest, [switch]$Prerelease) {
if (!(Get-Module VSSetup)) {
if (!(Get-Module VSSetup -ListAvailable)) {return}
Import-Module VSSetup
}
$items = @(
Get-VSSetupInstance -Prerelease:$Prerelease |
Select-VSSetupInstance -Version 15.0 -Require Microsoft.Component.MSBuild -Product *
)
if (!$items) {
if (!$Prerelease) {
Get-MSBuild15VSSetup -Bitness:$Bitness -Latest:$Latest -Prerelease
}
return
}
if ($items.Count -ge 2) {
$byProduct = {
if ($_.Product -eq 'Microsoft.VisualStudio.Product.Enterprise') {4}
elseif ($_.Product -eq 'Microsoft.VisualStudio.Product.Professional') {3}
elseif ($_.Product -eq 'Microsoft.VisualStudio.Product.Community') {2}
elseif ($_.Product -eq 'Microsoft.VisualStudio.Product.BuildTools') {1}
else {0}
}
if ($Latest) {
$items = $items | Sort-Object InstallationVersion, $byProduct
}
else {
$items = $items | Sort-Object $byProduct
}
}
Join-Path ($items[-1].InstallationPath) (Get-MSBuild15Path $Bitness)
}
function Get-MSBuild15Guess($Bitness, [switch]$Latest, [switch]$Prerelease) {
$Folder = if ($Prerelease) {'Preview'} else {'2017'}
if (!($root = ${env:ProgramFiles(x86)})) {$root = $env:ProgramFiles}
$items = @(Get-Item "$root\Microsoft Visual Studio\$Folder\*\$(Get-MSBuild15Path $Bitness)" -ErrorAction 0)
if (!$items) {
if (!$Prerelease) {
Get-MSBuild15Guess -Bitness:$Bitness -Latest:$Latest -Prerelease
}
return
}
if ($items.Count -ge 2) {
$byProduct = {
if ($_.FullName -like '*\Enterprise\*') {4}
elseif ($_.FullName -like '*\Professional\*') {3}
elseif ($_.FullName -like '*\Community\*') {2}
elseif ($_.FullName -like '*\BuildTools\*') {1}
else {0}
}
if ($Latest) {
$items = $items | Sort-Object {$_.VersionInfo.FileVersion}, $byProduct
}
else {
$items = $items | Sort-Object $byProduct
}
}
$items[-1].FullName
}
function Get-MSBuild15($Bitness, [switch]$Latest) {
if ($path = Get-MSBuild15VSSetup $Bitness -Latest:$Latest) {
$path
}
else {
Get-MSBuild15Guess $Bitness -Latest:$Latest
}
}
function Get-MSBuildOldVersion($Version, $Bitness) {
if ([System.IntPtr]::Size -eq 8 -and $Bitness -eq 'x86') {
$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\$Version"
}
else {
$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$Version"
}
$rp = [Microsoft.Win32.Registry]::GetValue($key, 'MSBuildToolsPath', '')
if ($rp) {
Join-Path $rp MSBuild.exe
}
}
function Get-MSBuildOldLatest($Bitness) {
$rp = @(Get-ChildItem HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions | Sort-Object {[Version]$_.PSChildName})
if ($rp) {
Get-MSBuildOldVersion $rp[-1].PSChildName $Bitness
}
}
$ErrorActionPreference = 1
try {
if ($Version -match '^(.*?)(x86)$') {
$Version = $matches[1]
$Bitness = $matches[2]
}
else {
$Bitness = ''
}
$v15 = [Version]'15.0'
$vMax = [Version]'9999.0'
if (!$Version) {$Version = '*'}
$vRequired = if ($Version -eq '*') {$vMax} else {[Version]$Version}
if ($vRequired -eq $v15) {
if ($path = Get-MSBuild15 $Bitness -Latest:$Latest) {
return $path
}
}
elseif ($vRequired -lt $v15) {
if ($path = Get-MSBuildOldVersion $Version $Bitness) {
return $path
}
}
elseif ($vRequired -eq $vMax) {
if ($path = Get-MSBuild15 $Bitness -Latest:$Latest) {
return $path
}
if ($path = Get-MSBuildOldLatest $Bitness) {
return $path
}
}
throw 'The specified version is not found.'
}
catch {
Write-Error "Cannot resolve MSBuild $Version : $_"
}
<#
.Synopsis
Shows Invoke-Build task help information.
Copyright (c) Roman Kuzmin
.Description
The command shows the specified tasks help information as task names with
synopses, jobs with their locations, script parameters and environment. By
default, it analyses the code in order to extract variables in addition to
optionally documented in comments.
Synopsis is defined in task comments as # Synopsis: ...
Parameters are defined as # Parameters: name1, name2, ...
Environment variables are defined as # Environment: name1, name2, ...
Parameters names match build parameters and separated by spaces or commas.
Parameter descriptions are taken from the build script comment based help.
Help info members (for custom formatters):
Task: [object[]] Tasks to do.
Name: [string] Task name.
Synopsis: [string] Task synopsis, may be null.
Jobs: [object[]] Jobs to do.
Name: [string] Task name.
Location: [string] Task location as "<file>:<line>".
Parameters: [object[]] Tasks parameters, may be empty.
Name: [string] Parameter name.
Type: [string] Parameter type.
Description: [string] Parameter help, may be null or empty.
Environment: [string[]] Tasks environment variables, may be empty.
.Parameter Task
Build task name(s). The default is the usual default task.
.Parameter File
Build script path. The default is the usual default script.
.Parameter NoCode
Tells to skip code analysis for parameters and environment.
It is used as true for PowerShell v2.
.Parameter Format
Specifies the custom task help formatter.
.Link
https://github.com/nightroman/Invoke-Build
#>
param(
[Parameter(Position=0)][string[]]$Task,
[Parameter(Position=1)]$File,
$Format = 'Format-TaskHelp',
[switch]$NoCode
)
trap {$PSCmdlet.ThrowTerminatingError($_)}
$ErrorActionPreference = 1
if ([System.IO.Path]::GetFileName($MyInvocation.ScriptName) -eq 'Invoke-Build.ps1') {
$all = ${*}.All
Remove-Variable Task
}
else {
$BuildTask = $Task
$BuildFile = $File
. Invoke-Build
### resolve file
if ($BuildFile) {
$BuildFile = *Path $BuildFile
if (![System.IO.File]::Exists($BuildFile)) {*Fin "Missing file '$BuildFile'." 5}
}
else {
$BuildFile = Get-BuildFile (*Path)
if (!$BuildFile) {*Fin 'Missing default script.' 5}
}
### resolve task
$all = Invoke-Build ?? $BuildFile
if (!$BuildTask -or '.' -eq $BuildTask) {
$BuildTask = if ($all['.']) {'.'} else {$all.Item(0).Name}
}
}
### get script parameter help
$Help = @(&{
Set-StrictMode -Off
if ($r = Get-Help $BuildFile) {if ($r = $r.parameters) {if ($r = $r.parameter) {$r}}}
})
### get script parameters
$CommonParameters = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'ErrorVariable', 'WarningVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable', 'InformationAction', 'InformationVariable'
$Parameters = (Get-Command $BuildFile).Parameters
foreach($name in @($Parameters.Keys)) {
if ($CommonParameters -contains $name) {
$null = $Parameters.Remove($name)
}
}
# amend options
$NoCode = $NoCode -or $PSVersionTable.PSVersion.Major -le 2
# globals
$Hash = @{}
$BuildJobs = @()
$MapParameter = @{}
$MapEnvironment = @{}
$VariableExpressionAst = {$args[0] -is [System.Management.Automation.Language.VariableExpressionAst]}
# collect jobs to do in $BuildJobs
function Add-TaskJob($Jobs, $Task) {
foreach($job in $Jobs) {
$job, $null = *Job $job
if ($job -is [string]) {
$task2 = $all[$job]
Add-TaskJob $task2.Jobs $task2
}
else {
if ($BuildJobs -notcontains $Task.Name) {
$script:BuildJobs += $Task.Name
}
}
}
if ($Task -and $Task.If -is [scriptblock]) {
if ($BuildJobs -notcontains $Task.Name) {
$script:BuildJobs += $Task.Name
}
}
}
# get parameters and environment from comments
function Get-TaskComment($Task) {
$f = ($I = $Task.InvocationInfo).ScriptName
if (!($d = $Hash[$f])) {
$Hash[$f] = $d = @{T = Get-Content -LiteralPath $f; C = @{}}
foreach($_ in [System.Management.Automation.PSParser]::Tokenize($d.T, [ref]$null)) {
if ($_.Type -eq 15) {$d.C[$_.EndLine] = $_.Content}
}
}
$r = @{Parameters = @(); Environment = @()}
for($n = $I.ScriptLineNumber; --$n -ge 1) {
if ($c = $d.C[$n]) {
if ($c -match '(?m)^\s*#*\s*Parameters\s*:(.*)') {$r.Parameters = $Matches[1].Trim() -split '[\s,]+'}
elseif ($c -match '(?m)^\s*#*\s*Environment\s*:(.*)') {$r.Environment = $Matches[1].Trim() -split '[\s,]+'}
}
elseif ($d.T[$n - 1].Trim()) {
break
}
}
$r
}
function Add-VariablePath($Path) {
$index = $Path.IndexOf(':')
if ($index -ge 0) {
$prefix = $Path.Substring(0, $index)
$name = $Path.Substring($index + 1)
}
else {
$prefix = ''
$name = $Path
}
if (!$prefix -or $prefix -eq 'script') {
if ($Parameters.ContainsKey($name)) {
$MapParameter[$name] = 1
}
}
elseif ($prefix -eq 'env') {
$MapEnvironment[$name] = 1
}
}
function Add-BlockVariable($Block) {
$variables = $job.Ast.FindAll($VariableExpressionAst, $true)
foreach($variable in $variables) {
$parent = $variable.Parent
if ($parent -isnot [System.Management.Automation.Language.AssignmentStatementAst] -or $parent.Left -ne $variable) {
Add-VariablePath $variable.VariablePath.UserPath
}
}
}
function Add-TaskVariable($Jobs) {
foreach($job in $Jobs) {
$task = $all[$job]
$info = Get-TaskComment $task
foreach($name in $info.Environment) {
$MapEnvironment[$name] = 1
}
foreach($name in $info.Parameters) {
if ($Parameters.ContainsKey($name)) {
$MapParameter[$name] = 1
}
else {
Write-Warning "Task '$($task.Name)': unknown parameter '$name'."
}
}
if (!$NoCode) {
$job = $Task.If
if ($job -is [scriptblock]) {
Add-BlockVariable $job
}
foreach($job in $task.Jobs) {
if ($job -is [scriptblock]) {
Add-BlockVariable $job
}
}
}
}
}
function Format-TaskHelp($TaskHelp) {
Write-Build White Task:
foreach($r in $TaskHelp.Task) {
if ($r.Synopsis) {
Write-Build Gray (' {0} - {1}' -f $r.Name, $r.Synopsis)
}
else {
Write-Build Gray (' {0}' -f $r.Name)
}
}
Write-Build White Jobs:
foreach($r in $TaskHelp.Jobs) {
Write-Build Gray (' {0} - {1}' -f $r.Name, $r.Location)
}
if ($TaskHelp.Parameters) {
Write-Build White Parameters:
foreach($param in $TaskHelp.Parameters) {
Write-Build Gray (' [{0}] {1}' -f $param.Type, $param.Name)
if ($param.Description) {
Write-Build Gray (' {0}' -f $param.Description)
}
}
}
if ($TaskHelp.Environment) {
Write-Build White Environment:
Write-Build Gray (' {0}' -f ($TaskHelp.Environment -join ', '))
}
}
### .Task
$TaskHelp = 1 | Select-Object Task, Jobs, Synopsis, Location, Parameters, Environment
$TaskHelp.Task = @(
foreach($job in $BuildTask) {
$job, $null = *Job $job
$task = $all[$job]
if (!$task) {*Fin "Missing task '$job' in '$BuildFile'." 5}
$r = 1 | Select-Object Name, Synopsis
$r.Name = $task.Name
$r.Synopsis = Get-BuildSynopsis $task $Hash
$r
}
)
### .Jobs
Add-TaskJob $BuildTask
$TaskHelp.Jobs = @(
foreach($name in $BuildJobs) {
$task = $all[$name]
$r = 1 | Select-Object Name, Location
$r.Name = $task.Name
$r.Location = '{0}:{1}' -f $task.InvocationInfo.ScriptName, $task.InvocationInfo.ScriptLineNumber
$r
}
)
### .Parameters and .Environment
Add-TaskVariable $BuildJobs
$TaskHelp.Environment = @($MapEnvironment.Keys | Sort-Object)
# make parameter objects with help
$TaskHelp.Parameters = @()
foreach($name in $MapParameter.Keys) {
$param = $Parameters[$name]
$r = 1 | Select-Object Name, Type, Description
$r.Name = $name
$type = $param.ParameterType.Name
if ($type -eq 'SwitchParameter') {
$r.Type = 'switch'
}
else {
$r.Type = $type
}
$r.Description = foreach($_ in $Help) {
if ($_.name -eq $name -and $_.PSObject.Properties['description']) {
($_.description | Out-String).Trim()
break
}
}
$TaskHelp.Parameters += $r
}
$TaskHelp.Parameters = @($TaskHelp.Parameters | Sort-Object {$_.Type -eq 'switch'}, Name)
# finish
& $Format $TaskHelp
<#PSScriptInfo
.VERSION 1.1.5
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.TAGS Invoke, Task, Invoke-Build, VSCode
.GUID b8b2b532-28f6-443a-b0b1-079a66dd4ce3
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>
<#
.Synopsis
Makes VSCode tasks from Invoke-Build tasks
.Description
The script creates "./.vscode/tasks.json". The existing file is replaced.
Change to the VSCode workspace directory before invoking the script.
Generated VSCode tasks call Invoke-Build tasks.
Do not edit "tasks.json" directly. Edit the build script instead. When you
add, remove, rename tasks, or change script locations then regenerate.
The default task becomes the so called VSCode build task (Ctrl+Shift+B).
The default task is "." if it exists, otherwise it is the first task.
To invoke another task from VSCode, hit F1 or Ctrl+Shift+P, type "Run
Task", type a task name or select it from the task list. Even better,
set your keyboard shortcut for "workbench.action.tasks.runTask".
Only tasks with certain names are included. They contain alphanumeric
characters, "_", ".", and "-", with the first character other than "-".
.Parameter BuildFile
Specifies the build script path, absolute or relative. By default it is
the default script in the current location, i.e. in the workspace root.
.Parameter InvokeBuild
Specifies the Invoke-Build.ps1 path, absolute or relative. If it is not
specified then any found in the workspace is used. If there is none
then the command Invoke-Build is used.
.Example
> New-VSCodeTask
This command binds to the default build script in the workspace root and
Invoke-Build.ps1 either in the workspace root or subdirectory or in the
path or the module command.
.Example
> New-VSCodeTask ./Scripts/Build.ps1 ./packages/InvokeBuild/Invoke-Build.ps1
This command uses relative build and engine script paths. The second may be
omitted, Invoke-Build.ps1 will be discovered. But it is needed if there may
be several Invoke-Build.ps1 in the workspace.
#>
[CmdletBinding()]
param(
[string]$BuildFile,
[string]$InvokeBuild
)
function Add-Text($Text) {$null = $out.Append($Text)}
function Add-Line($Text) {$null = $out.AppendLine($Text)}
trap {$PSCmdlet.ThrowTerminatingError($_)}
$ErrorActionPreference = 'Stop'
# resolve Invoke-Build.ps1
if (!$InvokeBuild) {
$InvokeBuild2 = @(Get-ChildItem . -Name -Recurse -Filter Invoke-Build.ps1)
$InvokeBuild = if ($InvokeBuild2) {
'./{0}' -f $InvokeBuild2[0]
} else {
'Invoke-Build'
}
}
$InvokeBuild2 = if ($InvokeBuild -eq 'Invoke-Build') {
'Invoke-Build'
}
else {
"& '{0}'" -f $InvokeBuild.Replace('\', '/').Replace("'", "''")
}
# get all tasks and the default task
$all = & $InvokeBuild ?? -File $BuildFile
$dot = if ($all['.']) {'.'} else {$all.Item(0).Name}
# tasks.json header
$out = New-Object System.Text.StringBuilder
Add-Line '// Do not edit! This file is generated by New-VSCodeTask.ps1'
Add-Line '// Modify the build script instead and regenerate this file.'
Add-Line '{'
Add-Line ' "version": "2.0.0",'
Add-Line ' "windows": {'
Add-Line ' "options": {'
Add-Line ' "shell": {'
Add-Line ' "executable": "powershell.exe",'
Add-Line ' "args": [ "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command" ]'
Add-Line ' }'
Add-Line ' }'
Add-Line ' },'
Add-Line ' "linux": {'
Add-Line ' "options": {'
Add-Line ' "shell": {'
Add-Line ' "executable": "/usr/bin/pwsh",'
Add-Line ' "args": [ "-NoProfile", "-Command" ]'
Add-Line ' }'
Add-Line ' }'
Add-Line ' },'
Add-Line ' "osx": {'
Add-Line ' "options": {'
Add-Line ' "shell": {'
Add-Line ' "executable": "/usr/local/bin/pwsh",'
Add-Line ' "args": [ "-NoProfile", "-Command" ]'
Add-Line ' }'
Add-Line ' }'
Add-Line ' },'
Add-Line ' "tasks": ['
# tasks.json tasks
$BuildFile2 = if ($BuildFile) {" -File '{0}'" -f $BuildFile.Replace('\', '/').Replace("'", "''")} else {''}
foreach($task in $all.Values) {
$name = $task.Name
if ($name -match '[^\w\.\-]|^-') {
continue
}
Add-Line (' {')
Add-Line (' "label": "{0}",' -f $name)
Add-Line (' "type": "shell",')
Add-Line (' "problemMatcher": [ "$msCompile" ],')
if ($name -eq $dot) {
Add-Line ' "group": {'
Add-Line ' "kind": "build",'
Add-Line ' "isDefault": true'
Add-Line ' },'
}
Add-Line (' "command": "{0} -Task {1}{2}"' -f $InvokeBuild2, $name, $BuildFile2)
Add-Line (' },')
}
# last task and ending
Add-Line (' {')
Add-Line (' "label": "?",')
Add-Line (' "type": "shell",')
Add-Line (' "problemMatcher": [],')
Add-Line (' "command": "{0} -Task ?{1}"' -f $InvokeBuild2, $BuildFile2)
Add-Line (' }')
Add-Line (' ]')
Add-Text ('}')
# save the file
if (!(Test-Path .vscode)) {
$null = mkdir .vscode
}
Set-Content ./.vscode/tasks.json $out.ToString() -Encoding UTF8
<#
.Synopsis
Shows Invoke-Build task graph using DGML.
Copyright (c) Roman Kuzmin
.Description
Requires:
- Visual Studio: Individual components \ Code tools \ DGML editor.
- Invoke-Build is in the path or available as the module command.
The script calls Invoke-Build in order to get the tasks, builds the DGML
and invokes the associated application (Visual Studio) in order to show it.
Tasks with code are shown as boxes, tasks without code are shown as ovals.
Safe references are shown with dotted edges, regular calls are shown with
solid edges. Job numbers are not shown by default.
EXAMPLES
# Make and show DGML for the default build script
Show-BuildDgml
# Make Build.dgml with job numbers
Show-BuildDgml -Number -NoShow -Output Build.dgml
.Parameter File
See: help Invoke-Build -Parameter File
.Parameter Output
The output file and the format specified by its extension.
The default is "$env:TEMP\name-xxxxxxxx.dgml".
.Parameter Parameters
Build script parameters needed in special cases when they alter tasks.
.Parameter NoShow
Tells to create the output file without showing it.
In this case Output is normally specified by a caller.
.Parameter Number
Tells to show task job numbers. Jobs are tasks (numbers are shown on
edges) and own scripts (numbers are shown in task boxes after names).
.Link
https://github.com/nightroman/Invoke-Build
#>
param(
[Parameter(Position=0)]
[string]$File,
[Parameter(Position=1)]
[string]$Output,
[hashtable]$Parameters,
[switch]$NoShow,
[switch]$Number
)
trap {$PSCmdlet.ThrowTerminatingError($_)}
$ErrorActionPreference = 'Stop'
# output
if (!$Output) {
$path = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($(if ($File) {$File} else {''}))
$name = [System.IO.Path]::GetFileNameWithoutExtension($path)
$hash = '{0:x8}' -f ($path.ToUpper().GetHashCode())
$Output = "$env:TEMP\$name-$hash.dgml"
}
# get tasks
if (!$Parameters) {$Parameters = @{}}
$all = Invoke-Build ?? $File @Parameters
# synopses
$docs = @{}
. Invoke-Build
# make DGML
$xml = [xml]'<?xml version="1.0" encoding="utf-8"?><DirectedGraph/>'
$doc = $xml.DocumentElement
$nodes = $doc.AppendChild($xml.CreateElement('Nodes'))
$links = $doc.AppendChild($xml.CreateElement('Links'))
$styles = $doc.AppendChild($xml.CreateElement('Styles'))
$styles.InnerXml = @'
<Style TargetType="Node">
<Condition Expression="HasCategory('Calls')" />
<Setter Property="NodeRadius" Value="15" />
</Style>
<Style TargetType="Node">
<Condition Expression="HasCategory('Script')" />
<Setter Property="NodeRadius" Value="2" />
</Style>
'@
foreach($it in $all.Values) {
$name = $it.Name
$node = $nodes.AppendChild($xml.CreateElement('Node'))
$node.SetAttribute('Id', $name)
if ($synopsis = Get-BuildSynopsis $it $docs) {
$node.SetAttribute('Synopsis', $synopsis)
}
$num = 0
$script = ''
foreach($job in $it.Jobs) {
++$num
if ($job -is [string]) {
$job, $safe = if ($job[0] -eq '?') {$job.Substring(1), 1} else {$job}
$link = $links.AppendChild($xml.CreateElement('Link'))
$link.SetAttribute('Source', $name)
$link.SetAttribute('Target', $job)
if ($Number) {
$link.SetAttribute('Label', $num)
}
if ($safe) {
$link.SetAttribute('StrokeDashArray', '2 2')
}
}
else {
$script += "{$num}"
}
}
if ($script) {
$node.SetAttribute('Category', 'Script')
if ($Number) {
$node.SetAttribute('Label', "$name $script")
}
}
else {
$node.SetAttribute('Category', 'Calls')
}
}
# save DGML
$doc.SetAttribute('xmlns', 'http://schemas.microsoft.com/vs/2009/dgml')
$xml.Save($Output)
# show
if ($NoShow) {return}
Invoke-Item $Output
<#
.Synopsis
Shows Invoke-Build task trees with brief information.
Copyright (c) Roman Kuzmin
.Description
This script analyses task references and shows parent tasks and child trees
for the specified tasks. Tasks are not invoked.
.Parameter Task
Task names.
If it is "*" then all root tasks are used.
If it is omitted or "." then the default task is used.
.Parameter File
The build script.
If it is omitted then the default script is used.
.Parameter Parameters
Build script parameters needed in special cases when they alter tasks.
.Parameter Upstream
Tells to show upstream tasks for each task.
.Inputs
None.
.Outputs
Specified task trees.
.Link
https://github.com/nightroman/Invoke-Build
#>
param(
[Parameter(Position=0)][string[]]$Task,
[Parameter(Position=1)][string]$File,
[Parameter(Position=2)][hashtable]$Parameters,
[switch]$Upstream
)
$private:_Task = $Task
$private:_File = $File
$private:_Parameters = if ($Parameters) {$Parameters} else {@{}}
$private:_Upstream = $Upstream
Remove-Variable Task, File, Parameters, Upstream
# Shows the task tree.
function ShowTaskTree($Task, $Docs, $Step = 0) {
if ($Step -eq 0) {''}
$tab = ' ' * $Step
++$Step
# synopsis
$synopsis = Get-BuildSynopsis $Task $docs
# name
$info = $tab + $Task.Name
# upstream
if ($references.Count) {
$reference = $references[$Task]
if ($reference.Count) {
$info += ' (' + (($reference.Keys | Sort-Object) -join ', ') + ')'
}
}
# synopsis, output
if ($synopsis) {"$info # $synopsis"} else {$info}
# task jobs
foreach($_ in $Task.Jobs) {
if ($_ -is [string]) {
$r, $s = *Job $_
ShowTaskTree $tasks[$r] $Docs $Step
}
else {
$tab + ' {}'
}
}
}
$ErrorActionPreference = 'Stop'
try {
. Invoke-Build
# get tasks
$tasks = Invoke-Build ?? $_File @_Parameters
# references
$references = @{}
if ($_Upstream) {
foreach($it in $tasks.Values) {
$references[$it] = @{}
}
foreach($it in $tasks.Values) {foreach($job in $it.Jobs) {if ($job -is [string]) {
$references[$tasks[$job]][$it.Name] = 0
}}}
}
# resolve task
if ($_Task -eq '*') {
$_Task = :task foreach($_ in $tasks.Keys) {
foreach($task in $tasks.Values) {
if ($task.Jobs -contains $_ -or $task.Jobs -contains "?$_") {
continue task
}
}
$_
}
}
elseif (!$_Task -or '.' -eq $_Task) {
$_Task = if ($tasks['.']) {'.'} else {$tasks.Item(0).Name}
}
# test tasks
foreach($name in $_Task) {
if (!$tasks[$name]) {throw "Missing task '$name'."}
}
# show trees
$docs = @{}
foreach($name in $_Task) {
ShowTaskTree $tasks[$name] $docs
}
}
catch {
if ($_.InvocationInfo.ScriptName -ne $MyInvocation.MyCommand.Path) {throw}
$PSCmdlet.ThrowTerminatingError($_)
}
<#
.Synopsis
Shows Invoke-Build task help information.
Copyright (c) Roman Kuzmin
.Description
The command shows the specified tasks help information as task names with
synopses, jobs with their locations, script parameters and environment. By
default, it analyses the code in order to extract variables in addition to
optionally documented in comments.
Synopsis is defined in task comments as # Synopsis: ...
Parameters are defined as # Parameters: name1, name2, ...
Environment variables are defined as # Environment: name1, name2, ...
Parameters names match build parameters and separated by spaces or commas.
Parameter descriptions are taken from the build script comment based help.
Help info members (for custom formatters):
Task: [object[]] Tasks to do.
Name: [string] Task name.
Synopsis: [string] Task synopsis, may be null.
Jobs: [object[]] Jobs to do.
Name: [string] Task name.
Location: [string] Task location as "<file>:<line>".
Parameters: [object[]] Tasks parameters, may be empty.
Name: [string] Parameter name.
Type: [string] Parameter type.
Description: [string] Parameter help, may be null or empty.
Environment: [string[]] Tasks environment variables, may be empty.
.Parameter Task
Build task name(s). The default is the usual default task.
.Parameter File
Build script path. The default is the usual default script.
.Parameter NoCode
Tells to skip code analysis for parameters and environment.
It is used as true for PowerShell v2.
.Parameter Format
Specifies the custom task help formatter.
.Link
https://github.com/nightroman/Invoke-Build
#>
param(
[Parameter(Position=0)][string[]]$Task,
[Parameter(Position=1)]$File,
$Format = 'Format-TaskHelp',
[switch]$NoCode
)
trap {$PSCmdlet.ThrowTerminatingError($_)}
$ErrorActionPreference = 1
if ([System.IO.Path]::GetFileName($MyInvocation.ScriptName) -eq 'Invoke-Build.ps1') {
$all = ${*}.All
Remove-Variable Task
}
else {
$BuildTask = $Task
$BuildFile = $File
. Invoke-Build
### resolve file
if ($BuildFile) {
$BuildFile = *Path $BuildFile
if (![System.IO.File]::Exists($BuildFile)) {*Fin "Missing file '$BuildFile'." 5}
}
else {
$BuildFile = Get-BuildFile (*Path)
if (!$BuildFile) {*Fin 'Missing default script.' 5}
}
### resolve task
$all = Invoke-Build ?? $BuildFile
if (!$BuildTask -or '.' -eq $BuildTask) {
$BuildTask = if ($all['.']) {'.'} else {$all.Item(0).Name}
}
}
### get script parameter help
$Help = @(&{
Set-StrictMode -Off
if ($r = Get-Help $BuildFile) {if ($r = $r.parameters) {if ($r = $r.parameter) {$r}}}
})
### get script parameters
$CommonParameters = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'ErrorVariable', 'WarningVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable', 'InformationAction', 'InformationVariable'
$Parameters = (Get-Command $BuildFile).Parameters
foreach($name in @($Parameters.Keys)) {
if ($CommonParameters -contains $name) {
$null = $Parameters.Remove($name)
}
}
# amend options
$NoCode = $NoCode -or $PSVersionTable.PSVersion.Major -le 2
# globals
$Hash = @{}
$BuildJobs = @()
$MapParameter = @{}
$MapEnvironment = @{}
$VariableExpressionAst = {$args[0] -is [System.Management.Automation.Language.VariableExpressionAst]}
# collect jobs to do in $BuildJobs
function Add-TaskJob($Jobs, $Task) {
foreach($job in $Jobs) {
$job, $null = *Job $job
if ($job -is [string]) {
$task2 = $all[$job]
Add-TaskJob $task2.Jobs $task2
}
else {
if ($BuildJobs -notcontains $Task.Name) {
$script:BuildJobs += $Task.Name
}
}
}
if ($Task -and $Task.If -is [scriptblock]) {
if ($BuildJobs -notcontains $Task.Name) {
$script:BuildJobs += $Task.Name
}
}
}
# get parameters and environment from comments
function Get-TaskComment($Task) {
$f = ($I = $Task.InvocationInfo).ScriptName
if (!($d = $Hash[$f])) {
$Hash[$f] = $d = @{T = Get-Content -LiteralPath $f; C = @{}}
foreach($_ in [System.Management.Automation.PSParser]::Tokenize($d.T, [ref]$null)) {
if ($_.Type -eq 15) {$d.C[$_.EndLine] = $_.Content}
}
}
$r = @{Parameters = @(); Environment = @()}
for($n = $I.ScriptLineNumber; --$n -ge 1) {
if ($c = $d.C[$n]) {
if ($c -match '(?m)^\s*#*\s*Parameters\s*:(.*)') {$r.Parameters = $Matches[1].Trim() -split '[\s,]+'}
elseif ($c -match '(?m)^\s*#*\s*Environment\s*:(.*)') {$r.Environment = $Matches[1].Trim() -split '[\s,]+'}
}
elseif ($d.T[$n - 1].Trim()) {
break
}
}
$r
}
function Add-VariablePath($Path) {
$index = $Path.IndexOf(':')
if ($index -ge 0) {
$prefix = $Path.Substring(0, $index)
$name = $Path.Substring($index + 1)
}
else {
$prefix = ''
$name = $Path
}
if (!$prefix -or $prefix -eq 'script') {
if ($Parameters.ContainsKey($name)) {
$MapParameter[$name] = 1
}
}
elseif ($prefix -eq 'env') {
$MapEnvironment[$name] = 1
}
}
function Add-BlockVariable($Block) {
$variables = $job.Ast.FindAll($VariableExpressionAst, $true)
foreach($variable in $variables) {
$parent = $variable.Parent
if ($parent -isnot [System.Management.Automation.Language.AssignmentStatementAst] -or $parent.Left -ne $variable) {
Add-VariablePath $variable.VariablePath.UserPath
}
}
}
function Add-TaskVariable($Jobs) {
foreach($job in $Jobs) {
$task = $all[$job]
$info = Get-TaskComment $task
foreach($name in $info.Environment) {
$MapEnvironment[$name] = 1
}
foreach($name in $info.Parameters) {
if ($Parameters.ContainsKey($name)) {
$MapParameter[$name] = 1
}
else {
Write-Warning "Task '$($task.Name)': unknown parameter '$name'."
}
}
if (!$NoCode) {
$job = $Task.If
if ($job -is [scriptblock]) {
Add-BlockVariable $job
}
foreach($job in $task.Jobs) {
if ($job -is [scriptblock]) {
Add-BlockVariable $job
}
}
}
}
}
function Format-TaskHelp($TaskHelp) {
Write-Build White Task:
foreach($r in $TaskHelp.Task) {
if ($r.Synopsis) {
Write-Build Gray (' {0} - {1}' -f $r.Name, $r.Synopsis)
}
else {
Write-Build Gray (' {0}' -f $r.Name)
}
}
Write-Build White Jobs:
foreach($r in $TaskHelp.Jobs) {
Write-Build Gray (' {0} - {1}' -f $r.Name, $r.Location)
}
if ($TaskHelp.Parameters) {
Write-Build White Parameters:
foreach($param in $TaskHelp.Parameters) {
Write-Build Gray (' [{0}] {1}' -f $param.Type, $param.Name)
if ($param.Description) {
Write-Build Gray (' {0}' -f $param.Description)
}
}
}
if ($TaskHelp.Environment) {
Write-Build White Environment:
Write-Build Gray (' {0}' -f ($TaskHelp.Environment -join ', '))
}
}
### .Task
$TaskHelp = 1 | Select-Object Task, Jobs, Synopsis, Location, Parameters, Environment
$TaskHelp.Task = @(
foreach($job in $BuildTask) {
$job, $null = *Job $job
$task = $all[$job]
if (!$task) {*Fin "Missing task '$job' in '$BuildFile'." 5}
$r = 1 | Select-Object Name, Synopsis
$r.Name = $task.Name
$r.Synopsis = Get-BuildSynopsis $task $Hash
$r
}
)
### .Jobs
Add-TaskJob $BuildTask
$TaskHelp.Jobs = @(
foreach($name in $BuildJobs) {
$task = $all[$name]
$r = 1 | Select-Object Name, Location
$r.Name = $task.Name
$r.Location = '{0}:{1}' -f $task.InvocationInfo.ScriptName, $task.InvocationInfo.ScriptLineNumber
$r
}
)
### .Parameters and .Environment
Add-TaskVariable $BuildJobs
$TaskHelp.Environment = @($MapEnvironment.Keys | Sort-Object)
# make parameter objects with help
$TaskHelp.Parameters = @()
foreach($name in $MapParameter.Keys) {
$param = $Parameters[$name]
$r = 1 | Select-Object Name, Type, Description
$r.Name = $name
$type = $param.ParameterType.Name
if ($type -eq 'SwitchParameter') {
$r.Type = 'switch'
}
else {
$r.Type = $type
}
$r.Description = foreach($_ in $Help) {
if ($_.name -eq $name -and $_.PSObject.Properties['description']) {
($_.description | Out-String).Trim()
break
}
}
$TaskHelp.Parameters += $r
}
$TaskHelp.Parameters = @($TaskHelp.Parameters | Sort-Object {$_.Type -eq 'switch'}, Name)
# finish
& $Format $TaskHelp
Log in or click on link to see number of positives.
- invoke-build.5.2.1.nupkg (7818f69ad05a) - ## / 51
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.11.3 | 361 | Saturday, July 6, 2024 | Approved | |
Invoke-Build 5.11.2 | 114 | Wednesday, June 12, 2024 | Approved | |
Invoke-Build 5.11.1 | 209 | Sunday, April 14, 2024 | Approved | |
Invoke-Build 5.11.0 | 206 | Saturday, March 9, 2024 | Approved | |
Invoke-Build 5.10.6 | 44 | Tuesday, March 5, 2024 | Approved | |
Invoke-Build 5.10.5 | 327 | Saturday, December 16, 2023 | Approved | |
Invoke-Build 5.10.4 | 828 | Tuesday, May 16, 2023 | Approved | |
Invoke-Build 5.10.3 | 348 | Friday, March 10, 2023 | Approved | |
Invoke-Build 5.10.2 | 129 | Thursday, February 9, 2023 | Approved | |
Invoke-Build 5.10.1 | 427 | Tuesday, October 25, 2022 | Approved | |
Invoke-Build 5.10.0 | 129 | Saturday, October 22, 2022 | Approved | |
Invoke-Build 5.9.12 | 808 | Saturday, September 17, 2022 | Approved | |
Invoke-Build 5.9.11 | 596 | Sunday, August 21, 2022 | Approved | |
Invoke-Build 5.9.10 | 1694 | Tuesday, April 12, 2022 | Approved | |
Invoke-Build 5.9.9.0 | 606 | Thursday, March 10, 2022 | Approved | |
Invoke-Build 5.9.8 | 138 | Monday, March 7, 2022 | Approved | |
Invoke-Build 5.9.7 | 400 | Thursday, February 10, 2022 | Approved | |
Invoke-Build 5.9.6 | 163 | Saturday, February 5, 2022 | Approved | |
Invoke-Build 5.9.5 | 101 | Friday, February 4, 2022 | Approved | |
Invoke-Build 5.9.4 | 136 | Wednesday, February 2, 2022 | Approved | |
Invoke-Build 5.9.3 | 130 | Saturday, January 29, 2022 | Approved | |
Invoke-Build 5.9.2 | 97 | Friday, January 28, 2022 | Approved | |
Invoke-Build 5.9.1 | 106 | Thursday, January 27, 2022 | Approved | |
Invoke-Build 5.9.0 | 244 | Monday, January 17, 2022 | Approved | |
Invoke-Build 5.8.8 | 276 | Sunday, January 2, 2022 | Approved | |
Invoke-Build 5.8.7 | 242 | Monday, December 13, 2021 | Approved | |
Invoke-Build 5.8.6 | 309 | Thursday, November 25, 2021 | Approved | |
Invoke-Build 5.8.5 | 356 | Wednesday, November 10, 2021 | Approved | |
Invoke-Build 5.8.4 | 1085 | Sunday, August 15, 2021 | Approved | |
Invoke-Build 5.8.3 | 91 | Saturday, August 14, 2021 | Approved | |
Invoke-Build 5.8.1 | 193 | Sunday, July 18, 2021 | Approved | |
Invoke-Build 5.8.0 | 998 | Friday, April 16, 2021 | Approved | |
Invoke-Build 5.7.3 | 300 | Saturday, March 27, 2021 | Approved | |
Invoke-Build 5.7.2 | 496 | Sunday, March 7, 2021 | Approved | |
Invoke-Build 5.7.1 | 220 | Saturday, February 27, 2021 | Approved | |
Invoke-Build 5.7.0 | 252 | Saturday, February 20, 2021 | Approved | |
Invoke-Build 5.6.5 | 924 | Monday, January 11, 2021 | Approved | |
Invoke-Build 5.6.4 | 248 | Thursday, December 17, 2020 | Approved | |
Invoke-Build 5.6.3 | 515 | Monday, November 23, 2020 | Approved | |
Invoke-Build 5.6.2 | 608 | Friday, September 11, 2020 | Approved | |
Invoke-Build 5.6.1 | 238 | Friday, August 7, 2020 | Approved | |
Invoke-Build 5.6.0 | 715 | Thursday, May 21, 2020 | Approved | |
Invoke-Build 5.5.11 | 285 | Tuesday, April 28, 2020 | Approved | |
Invoke-Build 5.5.9 | 261 | Wednesday, April 8, 2020 | Approved | |
Invoke-Build 5.5.8 | 367 | Tuesday, March 24, 2020 | Approved | |
Invoke-Build 5.5.7 | 339 | Friday, February 7, 2020 | Approved | |
Invoke-Build 5.5.6 | 225 | Monday, December 16, 2019 | Approved | |
Invoke-Build 5.5.5 | 241 | Thursday, October 17, 2019 | Approved | |
Invoke-Build 5.5.3 | 267 | Friday, August 30, 2019 | Approved | |
Invoke-Build 5.5.2 | 248 | Wednesday, June 12, 2019 | Approved | |
Invoke-Build 5.5.1 | 259 | Wednesday, April 10, 2019 | Approved | |
Invoke-Build 5.5.0 | 232 | Thursday, April 4, 2019 | Approved | |
Invoke-Build 5.4.6 | 190 | Thursday, March 28, 2019 | Approved | |
Invoke-Build 5.4.5 | 260 | Wednesday, March 6, 2019 | Approved | |
Invoke-Build 5.4.4 | 232 | Monday, February 25, 2019 | Approved | |
Invoke-Build 5.4.3 | 246 | Friday, February 15, 2019 | Approved | |
Invoke-Build 5.4.2 | 655 | Saturday, December 8, 2018 | Approved | |
Invoke-Build 5.4.1 | 693 | Thursday, April 12, 2018 | Approved | |
Invoke-Build 5.4.0 | 345 | Tuesday, April 3, 2018 | Approved | |
Invoke-Build 5.3.0 | 340 | Saturday, March 24, 2018 | Approved | |
Invoke-Build 5.2.1 | 333 | Tuesday, March 20, 2018 | Approved | |
Invoke-Build 5.2.0 | 355 | Tuesday, February 27, 2018 | Approved | |
Invoke-Build 5.1.1 | 334 | Thursday, February 15, 2018 | Approved | |
Invoke-Build 5.1.0 | 326 | Thursday, February 8, 2018 | Approved | |
Invoke-Build 5.0.1 | 370 | Tuesday, January 16, 2018 | Approved | |
Invoke-Build 5.0.0 | 357 | Tuesday, January 2, 2018 | Approved | |
Invoke-Build 4.2.0 | 339 | Wednesday, December 20, 2017 | Approved | |
Invoke-Build 4.1.2 | 396 | Thursday, December 7, 2017 | Approved | |
Invoke-Build 4.1.1 | 354 | Monday, December 4, 2017 | Approved | |
Invoke-Build 4.1.0 | 334 | Tuesday, November 28, 2017 | Approved | |
Invoke-Build 4.0.2 | 375 | Sunday, November 26, 2017 | Approved | |
Invoke-Build 4.0.1 | 337 | Thursday, November 23, 2017 | Approved | |
Invoke-Build 4.0.0 | 378 | Wednesday, November 15, 2017 | Approved | |
Invoke-Build 3.7.2 | 382 | Tuesday, November 7, 2017 | Approved | |
Invoke-Build 3.7.1 | 408 | Sunday, October 29, 2017 | Approved | |
Invoke-Build 3.6.5.20170830 | 468 | Wednesday, August 30, 2017 | Approved | |
Invoke-Build 3.6.4 | 444 | Saturday, July 29, 2017 | Approved | |
Invoke-Build 3.6.3 | 346 | Thursday, July 27, 2017 | Approved | |
Invoke-Build 3.6.2 | 371 | Friday, July 21, 2017 | Approved | |
Invoke-Build 3.6.1 | 384 | Saturday, July 15, 2017 | Approved | |
Invoke-Build 3.6.0 | 376 | Saturday, July 8, 2017 | Approved | |
Invoke-Build 3.5.3 | 399 | Friday, June 30, 2017 | Approved | |
Invoke-Build 3.5.2 | 381 | Tuesday, June 27, 2017 | Approved | |
Invoke-Build 3.5.1 | 417 | Thursday, June 22, 2017 | Approved | |
Invoke-Build 3.5.0 | 352 | Saturday, June 17, 2017 | Approved | |
Invoke-Build 3.4.0 | 385 | Thursday, June 8, 2017 | Approved | |
Invoke-Build 3.3.11 | 381 | Friday, June 2, 2017 | Approved | |
Invoke-Build 3.3.10 | 395 | Friday, May 26, 2017 | Approved | |
Invoke-Build 3.3.9 | 358 | Saturday, May 20, 2017 | Approved | |
Invoke-Build 3.3.8 | 455 | Friday, May 12, 2017 | Approved | |
Invoke-Build 3.3.7 | 364 | Tuesday, May 9, 2017 | Approved | |
Invoke-Build 3.3.6 | 355 | Sunday, April 30, 2017 | Approved | |
Invoke-Build 3.3.5 | 400 | Monday, April 24, 2017 | Approved | |
Invoke-Build 3.3.4 | 397 | Sunday, April 16, 2017 | Approved |
Roman Kuzmin
This package has no dependencies.
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.