This repository was archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.ps1
More file actions
58 lines (44 loc) · 1.64 KB
/
Copy pathBuild.ps1
File metadata and controls
58 lines (44 loc) · 1.64 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
Function check-result {
if ($LastExitCode -ne 0) {
$e = [char]27
$start = "$e[1;31m"
$end = "$e[m"
$text = "ERROR: Exiting with error code $LastExitCode"
Write-Host "$start$text$end"
return $false
}
return $true
}
Function Invoke-Exe {
Param(
[parameter(Mandatory=$true)][string] $cmd,
[parameter(Mandatory=$true)][string] $args
)
Write-Host "Executing: `"$cmd`" --% $args"
Invoke-Expression "& `"$cmd`" $args"
$result = check-result
if (!$result) {
throw "ERROR executing EXE"
}
}
#$ErrorActionPreference = 'Stop'
echo "build: Build started"
if(Test-Path .\artifacts) {
echo "build: Cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}
Invoke-Exe -cmd dotnet -args restore
#$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
#$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
#$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "1.0.0" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
echo "build: Version suffix is $suffix"
Get-ChildItem -include project.json -Recurse | Resolve-Path -Relative |
ForEach-Object{
$path = (Get-Item $_).DirectoryName
Write-Host "Found: $_ in $path"
# Push-Location -Path $path
# Invoke-Exe -cmd dotnet -args "version $version"
# Pop-Location
Invoke-Exe -cmd dotnet -args "build $path"
}