forked from datalust/seq-forwarder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.ps1
62 lines (50 loc) · 1.5 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
61
62
function Clean-Output
{
if(Test-Path ./artifacts) { rm ./artifacts -Force -Recurse }
}
function Restore-Packages
{
& nuget restore
}
function Update-AssemblyInfo($version)
{
$versionPattern = "[0-9]+(\.([0-9]+|\*)){3}"
foreach ($file in ls ./src/*/Properties/AssemblyInfo.cs)
{
(cat $file) | foreach {
% {$_ -replace $versionPattern, "$version.0" }
} | sc -Encoding "UTF8" $file
}
}
function Update-WixVersion($version)
{
$defPattern = "define Version = ""0\.0\.0"""
$def = "define Version = ""$version"""
$product = ".\setup\SeqForwarder\Product.wxs"
(cat $product) | foreach {
% {$_ -replace $defPattern, $def }
} | sc -Encoding "UTF8" $product
}
function Execute-MSBuild
{
& msbuild ./seq-forwarder.sln /t:Rebuild /p:Configuration=Release /p:Platform=x86
}
function Execute-Tests
{
& ./packages/xunit.runner.console.2.1.0/tools/xunit.console.x86.exe ./test/Seq.Forwarder.Tests/bin/Release/Seq.Forwarder.Tests.dll
}
function Publish-Artifacts($version)
{
mkdir ./artifacts
mv ./setup/SeqForwarder/bin/Release/SeqForwarder.msi ./artifacts/SeqForwarder-$version.msi
}
Push-Location $PSScriptRoot
$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "0.0.0" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
Clean-Output
Restore-Packages
Update-AssemblyInfo($version)
Update-WixVersion($version)
Execute-MSBuild
Execute-Tests
Publish-Artifacts($version)
Pop-Location