-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.ps1
79 lines (64 loc) · 3.19 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
########################
# THE BUILD!
########################
Push-Location $PSScriptRoot
try {
Import-Module $PSScriptRoot/build/Autofac.Build.psd1 -Force
$artifactsPath = "$PSScriptRoot/artifacts"
$packagesPath = "$artifactsPath/packages"
$globalJson = (Get-Content "$PSScriptRoot/global.json" | ConvertFrom-Json -NoEnumerate);
$sdkVersion = $globalJson.sdk.version
# Clean up artifacts folder
if (Test-Path $artifactsPath) {
Write-Message "Cleaning $artifactsPath folder"
Remove-Item $artifactsPath -Force -Recurse
}
# Install dotnet SDK versions during CI. In a local build we assume you have
# everything installed; on CI we'll force the install. If you install _any_
# SDKs, you have to install _all_ of them because you can't install SDKs in
# two different locations. dotnet CLI locates SDKs relative to the
# executable.
if ($Null -ne $env:APPVEYOR_BUILD_NUMBER) {
Install-DotNetCli -Version $sdkVersion
foreach ($additional in $globalJson.additionalSdks)
{
Install-DotNetCli -Version $additional;
}
}
# Write out dotnet information
& dotnet --info
# Set version suffix
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:APPVEYOR_REPO_BRANCH];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:APPVEYOR_BUILD_NUMBER];
$versionSuffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)).Replace('/', '-'))-$revision" }[$branch -eq "master" -and $revision -ne "local"]
Write-Message "Package version suffix is '$versionSuffix'"
# Package restore
Write-Message "Restoring packages"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot | Restore-DependencyPackages
# Build/package
Write-Message "Building projects and packages"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\src | Invoke-DotNetPack -PackagesPath $packagesPath -VersionSuffix $versionSuffix
# Test
Write-Message "Executing unit tests"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\test | Invoke-Test
if ($env:CI -eq "true") {
# Generate Coverage Report
Write-Message "Downloading and verifying Codecov Uploader"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://keybase.io/codecovsecurity/pgp_keys.asc -OutFile codecov.asc
gpg --no-default-keyring --keyring trustedkeys.gpg --import codecov.asc
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/linux/codecov -Outfile codecov
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/linux/codecov.SHA256SUM -Outfile codecov.SHA256SUM
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig -Outfile codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
chmod +x codecov
Write-Message "Generating Codecov Report"
& ./codecov -f "artifacts/coverage/*/coverage*.info"
}
# Finished
Write-Message "Build finished"
}
finally {
Pop-Location
}