Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93ab2b2
commit 0b2286f
Showing
7 changed files
with
141 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
<# | ||
.Synopsis | ||
Example of the custom file-task. | ||
.Description | ||
This script is a demo of incremental tasks and custom file-tasks. | ||
See "File.tasks.ps1" for the details of "file". | ||
A file-task is slightly easier to compose than similar "task". It is not a | ||
big deal but if incremental tasks are used often then "file" may be useful. | ||
.Example | ||
Invoke-Build * File.build.ps1 | ||
On the first run all tasks work and create "Task*.log" files. On next runs | ||
tasks are either skipped or invoked as soon as temp files are updated. | ||
#> | ||
|
||
# Import file-task. | ||
. .\File.tasks.ps1 | ||
|
||
# Gets *.tmp files from the temp directory. Used in two tasks. | ||
$GetTmpFiles = { [System.IO.Directory]::GetFiles($env:TEMP, '*.tmp') } | ||
|
||
# Synopsis: Log temp files using "task". | ||
task Task1 -Inputs $GetTmpFiles -Outputs Task1.log { | ||
"Doing $($Task.Name)..." | ||
$Inputs > $Outputs | ||
} | ||
|
||
# Synopsis: Log temp files using "file". | ||
file Task2 $GetTmpFiles Task2.log { | ||
"Doing $($Task.Name)..." | ||
$Inputs > $Outputs | ||
} | ||
|
||
# Synopsis: Partial "task" references "file" and uses its output as input. | ||
task Task3 -Partial -Inputs Task2.log -Outputs Task3.log Task2, {process{ | ||
"Doing $($Task.Name)..." | ||
Get-Content $_ > $2 | ||
}} | ||
|
||
# Synopsis: Partial "file" references "task" and uses its output as input. | ||
file Task4 -Partial Task1.log Task4.log Task1, {process{ | ||
"Doing $($Task.Name)..." | ||
Get-Content $_ > $2 | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
<# | ||
.Synopsis | ||
Defines the custom task "file". | ||
.Description | ||
Build scripts dot-source this script in order to use the task "file". | ||
A file-task is a task with simplified syntax similar to Rake "file". Inputs | ||
and Outputs are mandatory positional parameters, the names may be omitted. | ||
File-task parameters: | ||
Name, Jobs, If, Partial, Data, Done, Source - as usual | ||
Inputs, Outputs - as usual but mandatory positional | ||
Script scope names: | ||
Alias: file | ||
Function: Add-FileTask | ||
.Example | ||
> | ||
# Dot-source "file" definitions | ||
. <path>\File.tasks.ps1 | ||
# Add "file" tasks | ||
file Task1 <inputs> <outputs> { | ||
... | ||
} | ||
#> | ||
|
||
# New DSL word. | ||
Set-Alias file Add-FileTask | ||
|
||
# Wrapper of "task" which adds a customized task used as "file". | ||
# Mind setting "Source" for error messages and help comments. | ||
function Add-FileTask( | ||
[Parameter(Position=0, Mandatory=1)][string]$Name, | ||
[Parameter(Position=1, Mandatory=1)]$Inputs, | ||
[Parameter(Position=2, Mandatory=1)]$Outputs, | ||
[Parameter(Position=3)][object[]]$Jobs, | ||
$If=1, | ||
$Data, | ||
$Done, | ||
$Source = $MyInvocation, | ||
[switch]$Partial | ||
) | ||
{ | ||
task @PSBoundParameters | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
@echo off | ||
rem ib.cmd - Invoke-Build helper for cmd.exe | ||
rem ib.cmd must be in the same directory as Invoke-Build.ps1 | ||
|
||
if "%1"=="?" goto list | ||
|
||
PowerShell.exe -NoProfile -ExecutionPolicy Bypass "& '%~dp0\Invoke-Build.ps1'" %* | ||
exit /B %errorlevel% | ||
|
||
:list | ||
PowerShell.exe -NoProfile -ExecutionPolicy Bypass "& '%~dp0\Invoke-Build.ps1'" %* "| Format-Table -AutoSize" |