-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Build-JustTask.ps1
48 lines (43 loc) · 1.17 KB
/
Build-JustTask.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<#
.Synopsis
Builds just the specified tasks skipping referenced tasks.
Copyright (c) Roman Kuzmin
.Description
The script invokes Invoke-Build with the usual parameters, with at least
one task specified explicitly. The specified tasks are invoked without
their referenced tasks. This unusual scenario may be useful in special
cases like debugging or development of a particular task when its
referenced tasks are completed and may be safely skipped.
Not every task may be correctly invoked in this way. If referenced tasks
configure the build environment and variables then they must be invoked.
#>
param(
[Parameter(Position=0, Mandatory=1)]
[string[]]$Task
,
[Parameter(Position=1)]$File
,
[switch]$Safe
,
[switch]$Summary
)
$ErrorActionPreference = 1
try {
${*data} = @{
Task = $Task
XBuild = {
$tasks = ${*data}.Task
foreach($_ in ${*}.All.get_Values()) {
if ($tasks -notcontains $_.Name) {
$_.If = 0
}
}
}
}
Remove-Variable Task, File, Safe, Summary
Invoke-Build @PSBoundParameters -Result ${*data}
}
catch {
if ($_.InvocationInfo.ScriptName -notmatch '\b(Invoke-Build|Build-JustTask)\.ps1$') {throw}
$PSCmdlet.ThrowTerminatingError($_)
}