-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
66 lines (54 loc) · 1.89 KB
/
build.ps1
File metadata and controls
66 lines (54 loc) · 1.89 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
[CmdletBinding(PositionalBinding = $false)]
param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Arguments = @()
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
function ConvertTo-NukeArguments {
param(
[string[]]$InputArguments = @()
)
$effectiveArguments = @($InputArguments | Where-Object { $null -ne $_ })
if ($effectiveArguments.Count -eq 0) {
$helpArguments = [System.Collections.Generic.List[string]]::new()
$helpArguments.Add('--help')
return $helpArguments
}
$forwardedArguments = [System.Collections.Generic.List[string]]::new()
$hasExplicitTarget = $false
foreach ($argument in $effectiveArguments) {
if ($argument -match '^(--|-|/)(target|t)$') {
$hasExplicitTarget = $true
}
}
$firstArgument = $effectiveArguments[0]
if (-not $hasExplicitTarget -and
-not [string]::IsNullOrWhiteSpace($firstArgument) -and
-not $firstArgument.StartsWith('-') -and
-not $firstArgument.StartsWith('/')) {
$forwardedArguments.Add('--target')
}
foreach ($argument in $effectiveArguments) {
$forwardedArguments.Add([string]$argument)
}
return $forwardedArguments
}
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$projectPath = Join-Path $repoRoot 'build\Build.csproj'
$forwardedArguments = ConvertTo-NukeArguments -InputArguments $Arguments
$commandArguments = [System.Collections.Generic.List[string]]::new()
$commandArguments.Add('run')
$commandArguments.Add('--project')
$commandArguments.Add($projectPath)
$commandArguments.Add('--')
$commandArguments.Add('--root')
$commandArguments.Add($repoRoot)
foreach ($argument in @($forwardedArguments)) {
if ($null -ne $argument) {
$commandArguments.Add([string]$argument)
}
}
& dotnet @commandArguments
exit $LASTEXITCODE