forked from StackExchange/StackExchange.Precompilation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildAndPack.ps1
55 lines (48 loc) · 1.21 KB
/
BuildAndPack.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
param(
[parameter(Position=0)]
[string] $VersionSuffix,
[parameter(Position=1)]
[string] $GitCommitId,
[parameter(Position=2)]
[string[]] $MsBuildArgs,
[switch] $CIBuild
)
if (-not $semver)
{
set-variable -name semver -scope global -value (get-content .\semver.txt)
}
if ($VersionSuffix -or $CIBuild)
{
$version = "$semver$VersionSuffix"
}
else
{
$epoch = [math]::truncate((new-timespan -start (get-date -date "01/01/1970") -end (get-date)).TotalSeconds)
$version = "$semver-local$epoch"
}
if(-not $GitCommitId)
{
$GitCommitId = $(git rev-parse HEAD)
}
$solutionDir = "$((Resolve-Path .).Path)\"
$defaultArgs = "/v:n", "/nologo",
"/p:SolutionDir=$solutionDir",
"/p:RepositoryCommit=$GitCommitId",
"/p:Version=$version",
"/p:Configuration=Release",
"/p:SEPrecompilerPath=$solutionDir\StackExchange.Precompilation.Build\bin\Release\net472"
if ($MsBuildArgs)
{
$defaultArgs += $MsBuildArgs
}
& msbuild ($defaultArgs + "/t:Restore")
& msbuild ($defaultArgs + "/t:Build,Pack")
if ($LastExitCode -ne 0)
{
throw "MSBuild failed"
}
.\Test.ConsoleApp\bin\Release\net472\Test.ConsoleApp.exe
if ($LastExitCode -ne 0)
{
throw "Test.ConsoleApp failed to run"
}