forked from ReflectionMagic/ReflectionMagic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
36 lines (33 loc) · 1.45 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
param (
[string]$OutputDirectory = $PSScriptRoot,
[string]$TestResultOutputDirectory = (Join-Path $PSScriptRoot "TestResults"),
[string]$VersionSuffix = "local",
[string]$BuildConfiguration = "Release"
)
# Taken from psake https://github.com/psake/psake
<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}
exec { & dotnet clean -c $BuildConfiguration }
exec { & dotnet restore }
exec { & dotnet build -c $BuildConfiguration /p:VersionSuffix="$VersionSuffix" }
exec { & dotnet test -r $TestResultOutputDirectory -l trx --no-build --verbosity=normal -c $BuildConfiguration test/ReflectionMagicTests/ReflectionMagicTests.csproj }
exec { & dotnet pack --no-build /p:VersionSuffix="$VersionSuffix" -c $BuildConfiguration -o $OutputDirectory --include-symbols src/ReflectionMagic }