-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.ps1
81 lines (75 loc) · 4.68 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
[CmdLetBinding()]
param(
[Parameter(Mandatory=$false)][string]$NugetApiKey="",
[Parameter(Mandatory=$false)][string]$MygetApiKey=""
)
# terminate upon any error encountered
$ErrorActionPreference="Stop"
function Say($message)
{
Write-Host $message -foreground "Blue"
}
Say "nuget-apikey: $NugetApiKey"
Say "myget-apikey: $MygetApiKey"
# install .net core sdk
Say "dotnet-install: installing .net core 2.0 sdk"
.\build\dotnet-install.ps1 -Channel "2.0"
$DotNetVersion = dotnet --version
Say "dotnet-version: running on $DotNetVersion"
# restore and run tooling
Say "dotnet-restore: installing tools"
dotnet restore .\build\tools.csproj --packages .\build\tools --no-dependencies
if($Error.Count -ne 0 -or $LastExitCode -eq 0) {
Say "gitversion: detecting semantic version"
$MajorMinorPatch = .\build\tools\gitversion.commandline\3.6.5\tools\GitVersion.exe /output json /showvariable MajorMinorPatch
$InformationalVersion = .\build\tools\gitversion.commandline\3.6.5\tools\GitVersion.exe /output json /showvariable InformationalVersion
Say "gitversion: Major.Minor.Patch=$MajorMinorPatch"
Say "gitversion: InformationalVersion=$InformationalVersion"
# build, test, pack and push
Say "dotnet-build: building solution"
dotnet build .\src\All.sln --configuration Release /p:AssemblyVersion=$MajorMinorPatch /p:FileVersion=$MajorMinorPatch /p:InformationalVersion=$InformationalVersion /p:PackageVersion=$MajorMinorPatch
if($Error.Count -ne 0 -or $LastExitCode -eq 0) {
Push-Location
Set-Location -Path .\src\Projac.Tests
Say "dotnet-test: running tests"
dotnet test --no-build --configuration Release
Set-Location -Path ..\Projac.Sql.Tests
Say "dotnet-test: running sql tests"
dotnet test --no-build --configuration Release
Set-Location -Path ..\Projac.SqlClient.Tests
Say "dotnet-test: running sqlclient tests"
dotnet test --no-build --configuration Release
Set-Location -Path ..\Projac.SQLite.Tests
Say "dotnet-test: running sqlite tests"
dotnet test --no-build --configuration Release
if($Error.Count -ne 0 -or $LastExitCode -eq 0) {
Pop-Location
Say "dotnet-pack: packaging"
dotnet pack .\src\All.sln --no-build --configuration Release /p:AssemblyVersion=$MajorMinorPatch /p:FileVersion=$MajorMinorPatch /p:InformationalVersion=$InformationalVersion /p:PackageVersion=$MajorMinorPatch
if($LastExitCode -eq 0) {
if ($NugetApiKey -ne "") {
Say "dotnet-nuget-push: pushing projac package to nuget"
dotnet nuget push .\src\Projac\bin\Release\Projac.$MajorMinorPatch.nupkg --source https://www.nuget.org/api/v2/package --api-key $NugetApiKey
Say "dotnet-nuget-push: pushing projac.sql package to nuget"
dotnet nuget push .\src\Projac.Sql\bin\Release\Projac.Sql.$MajorMinorPatch.nupkg --source https://www.nuget.org/api/v2/package --api-key $NugetApiKey
Say "dotnet-nuget-push: pushing projac.sqlclient package to nuget"
dotnet nuget push .\src\Projac.SqlClient\bin\Release\Projac.SqlClient.$MajorMinorPatch.nupkg --source https://www.nuget.org/api/v2/package --api-key $NugetApiKey
Say "dotnet-nuget-push: pushing projac.sqlite package to nuget"
dotnet nuget push .\src\Projac.SQLite\bin\Release\Projac.SQLite.$MajorMinorPatch.nupkg --source https://www.nuget.org/api/v2/package --api-key $NugetApiKey
}
if ($MygetApiKey -ne "") {
Say "dotnet-nuget-push: pushing projac package to myget"
dotnet nuget push .\src\Projac\bin\Release\Projac.$MajorMinorPatch.nupkg --source https://www.myget.org/F/projac/api/v2/package --api-key $MygetApiKey
Say "dotnet-nuget-push: pushing projac.sql package to myget"
dotnet nuget push .\src\Projac.Sql\bin\Release\Projac.Sql.$MajorMinorPatch.nupkg --source https://www.myget.org/F/projac/api/v2/package --api-key $MygetApiKey
Say "dotnet-nuget-push: pushing projac.sqlclient package to myget"
dotnet nuget push .\src\Projac.SqlClient\bin\Release\Projac.SqlClient.$MajorMinorPatch.nupkg --source https://www.myget.org/F/projac/api/v2/package --api-key $MygetApiKey
Say "dotnet-nuget-push: pushing projac.sqlite package to myget"
dotnet nuget push .\src\Projac.SQLite\bin\Release\Projac.SQLite.$MajorMinorPatch.nupkg --source https://www.myget.org/F/projac/api/v2/package --api-key $MygetApiKey
}
}
} else {
Pop-Location
}
}
}