Skip to content

Commit

Permalink
v2.9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
nightroman committed May 29, 2014
1 parent 93ab2b2 commit 0b2286f
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 4 deletions.
1 change: 1 addition & 0 deletions .build.ps1
Expand Up @@ -55,6 +55,7 @@ task Package ConvertMarkdown, Help, GitStatus, {
# copy files
Copy-Item -Destination z\tools `
Convert-psake.ps1,
ib.cmd,
Invoke-Build.ps1,
Invoke-Build-Help.xml,
Invoke-Builds.ps1,
Expand Down
6 changes: 3 additions & 3 deletions Invoke-Build.ps1
Expand Up @@ -227,11 +227,11 @@ function Write-Build([ConsoleColor]$Color, [string]$Text) {
}

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

if ($MyInvocation.InvocationName -eq '.') {
return @'
Invoke-Build 2.9.7
Invoke-Build 2.9.8
Copyright (c) 2011-2014 Roman Kuzmin
Add-BuildTask (task)
Expand Down Expand Up @@ -463,7 +463,7 @@ function *Task {

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

Expand Down
12 changes: 11 additions & 1 deletion README.md
Expand Up @@ -31,6 +31,7 @@ are for built-in help, parallel builds, task visualization, and etc.

Extras

* *ib.cmd* is Invoke-Build helper for cmd.exe
* *Convert-psake.ps1* converts psake build scripts
* *Invoke-TaskFromISE.ps1* invokes a task from ISE
* *Show-BuildTree.ps1* shows task trees as text
Expand Down Expand Up @@ -60,7 +61,16 @@ subdirectory *"tools"*.

Copy *Invoke-Build.ps1*, *Invoke-Build-Help.xml*, and optionally other scripts
to a directory in the path. As a result, the engine is called from PowerShell
as `Invoke-Build` and help for `Get-Help` is available.
as `Invoke-Build` and help for `Get-Help` is available. Note that this is not
mandatory, any location is fine but in this case invocation requires a path,
absolute or relative.

With cmd.exe use the helper *ib.cmd*. For similar experience in interactive
PowerShell use an alias `ib` defined in the PowerShell profile (`$Profile`)

Set-Alias ib <path>\Invoke-Build.ps1

`<path>\` may be omitted in the script is in the system path.

## Getting help

Expand Down
17 changes: 17 additions & 0 deletions Release-Notes.md
Expand Up @@ -2,6 +2,23 @@
Invoke-Build Release Notes
==========================

## v2.9.8

Users ask for a common cmd.exe helper. I was reluctant for some reasons but now
is a good time, perhaps. Here is the proposal based on my own practice.

- *ib.cmd* is the proposed Invoke-Build helper for cmd.exe.
- For similar experience in interactive PowerShell use an alias `ib`.

Note that scripts should continue to use the command `Invoke-Build`. The `ib`
commands should be used with cmd.exe (*ib.cmd*) and in interactive PowerShell
(alias of *Invoke-Build.ps1* defined in the profile).

Custom tasks

- Added the sample custom rake-like task `file`. It is not a big deal but it
still may be useful. Besides, it comes with examples of incremental tasks.

## v2.9.7

Task help (*experimentally*). The *Jobs* is an array, not a text. With
Expand Down
48 changes: 48 additions & 0 deletions Tasks/File/File.build.ps1
@@ -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
}}
49 changes: 49 additions & 0 deletions Tasks/File/File.tasks.ps1
@@ -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
}
12 changes: 12 additions & 0 deletions ib.cmd
@@ -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"

0 comments on commit 0b2286f

Please sign in to comment.