This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
77 lines (65 loc) · 2.69 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
param(
$Configuration = 'Release'
)
$DotNetChannel = "Current";
$DotNetVersion = "2.1.302";
$DotNetInstallerUri = "https://dot.net/dotnet-install.ps1";
###########################################################################
# INSTALL .NET CORE CLI
###########################################################################
Function Remove-PathVariable([string]$VariableToRemove)
{
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
}
# Get .NET Core CLI path if installed.
$FoundDotNetCliVersion = $null;
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
$FoundDotNetCliVersion = dotnet --version;
}
if($FoundDotNetCliVersion -ne $DotNetVersion) {
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
if (!(Test-Path $InstallPath)) {
mkdir -Force $InstallPath | Out-Null;
}
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
}
###########################################################################
# RUN BUILD SCRIPT
###########################################################################
Push-Location
Invoke-Expression "dotnet restore"
Invoke-Expression "dotnet build -c $Configuration"
Get-ChildItem test -Recurse -Filter *.Tests.csproj | ForEach-Object {
Push-Location $_.DirectoryName
Invoke-Expression "dotnet test -c $Configuration /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info"
if($LASTEXITCODE -ne 0) {
Pop-Location;
Pop-Location;
exit $LASTEXITCODE;
}
Pop-Location;
}
Get-ChildItem src -Recurse -Filter *.csproj | ForEach-Object {
Push-Location $_.DirectoryName
Invoke-Expression "dotnet pack -c $Configuration -o $PSScriptRoot\artifacts"
if($LASTEXITCODE -ne 0) {
Pop-Location;
Pop-Location;
exit $LASTEXITCODE;
}
Pop-Location;
}
if($LASTEXITCODE -ne 0) {
Pop-Location;
exit $LASTEXITCODE;
}