-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
92 lines (73 loc) · 2.86 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
param([switch]$DisableBuild, [switch]$RunTests, [switch]$EnableCoverage, [switch]$EnableSonar, [switch]$Publish)
if (!!$env:APPVEYOR_REPO_TAG_NAME)
{
$version = $env:APPVEYOR_REPO_TAG_NAME
}
elseif(!!$env:APPVEYOR_BUILD_VERSION)
{
$version = $env:APPVEYOR_BUILD_VERSION
}
if($version -ne $null)
{
$env:Version = $version
}
if($EnableSonar)
{
}
if($DisableBuild -eq $false)
{
dotnet restore src
msbuild src
}
if($RunTests -or $EnableCoverage)
{
# Test
$serachDirs = [System.IO.Path]::Combine($PSScriptRoot, "src", "*", "bin", "Debug", "netcoreapp2.0")
$runTestsCmd = [System.Guid]::NewGuid().ToString("N") + ".cmd"
$runTestsCmd = Join-Path -Path $env:TEMP -ChildPath $runTestsCmd
$testAssemblies = ""
Get-ChildItem ./src/*.Tests | %{ $testAssemblies += "dotnet test `"" + $_.FullName + "`" --no-build`n" }
if (!!$testAssemblies) # Has test assemblies
{
$userDirectory = $env:USERPROFILE
if($IsMacOS)
{
$userDirectory = $env:HOME
}
[System.IO.File]::WriteAllText($runTestsCmd, $testAssemblies)
Write-Host $runTestsCmd
if ($EnableCoverage)
{
# Test & Code Coverage
$nugetPackages = [System.IO.Path]::Combine($userDirectory, ".nuget", "packages")
$openCover = [System.IO.Path]::Combine($nugetPackages, "OpenCover", "*", "tools", "OpenCover.Console.exe")
$openCover = Resolve-Path $openCover
$coveralls = [System.IO.Path]::Combine($nugetPackages, "coveralls.io", "*", "tools", "coveralls.net.exe")
$coveralls = Resolve-Path $coveralls
& $openCover -register:user -target:"$runTestsCmd" -searchdirs:"$serachDirs" -oldstyle -output:coverage.xml -skipautoprops -returntargetcode -filter:"+[ChilliCream*]*"
& $coveralls --opencover coverage.xml
}
else
{
# Test
& $runTestsCmd
}
}
}
if($EnableSonar)
{
}
if($Publish)
{
$dropRootDirectory = Join-Path -Path $PSScriptRoot -ChildPath "drop"
$win10x64 = Join-Path -Path $dropRootDirectory -ChildPath "win10-x64"
$ubuntu1404x64 = Join-Path -Path $dropRootDirectory -ChildPath "ubuntu.14.04-x64"
$osxx64 = Join-Path -Path $dropRootDirectory -ChildPath "osx-x64"
$all = Join-Path -Path $dropRootDirectory -ChildPath "all"
dotnet publish ./src/Generator.CLI -c Release -f netcoreapp2.0 -r win10-x64 -o $win10x64
dotnet publish ./src/Generator.CLI -c Release -f netcoreapp2.0 -r ubuntu.14.04-x64 -o $ubuntu1404x64
dotnet publish ./src/Generator.CLI -c Release -f netcoreapp2.0 -r osx-x64 -o $osxx64
dotnet publish ./src/Generator.CLI -c Release -f netcoreapp2.0 -o $all
./deploy/nuget.ps1 -Version $version -ApiKey $env:NUGET_APIKEY
./deploy/chocolatey.ps1 -Version $version -ApiKey $env:CHOCO_APIKEY
}