-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.ps1
60 lines (50 loc) · 1.32 KB
/
Build.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
49
50
51
52
53
54
55
56
57
58
59
60
param
(
[Parameter()]
[string] $Configuration = "Release",
[Parameter()]
[string] $BuildNumber = "+",
[Parameter()]
[string] $VersionSuffix = ""
)
Clear-Host
$ErrorActionPreference = "Stop"
$watch = [System.Diagnostics.Stopwatch]::StartNew()
$scriptPath = $PSScriptRoot
$productName = "Cornerstone"
if ($scriptPath.Length -le 0)
{
$scriptPath = "C:\Workspaces\GitHub\$productName"
}
try
{
Push-Location $scriptPath
# Prepare the build for versioning!
$newVersion = & "$scriptPath\IncrementVersion.ps1" -Build $BuildNumber
# Open-File "$scriptPath\IncrementVersion.ps1"
# $BuildNumber = 3
$nugetVersion = ([Version] $newVersion).ToString(3)
$msbuild = "C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\MSBuild.exe"
& $msbuild "$scriptPath\$productName.sln" /p:Configuration="$Configuration" /t:Rebuild /v:m /m
if ($VersionSuffix.Length -gt 0)
{
$nugetVersion = "$nugetVersion-$VersionSuffix"
}
if ($LASTEXITCODE -ne 0)
{
Write-Host "Build has failed! " $LASTEXITCODE $watch.Elapsed -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host
Write-Host "Build: " $watch.Elapsed -ForegroundColor Yellow
}
catch
{
Write-Host $_.Exception.ToString() -ForegroundColor Red
Write-Host "Build Failed:" $watch.Elapsed -ForegroundColor Red
exit $LASTEXITCODE
}
finally
{
Pop-Location
}