-
Notifications
You must be signed in to change notification settings - Fork 20
/
Build.ps1
40 lines (33 loc) · 1.18 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
[CmdletBinding()]
param (
[Parameter(HelpMessage="The action to execute.")]
[ValidateSet("Build", "Test", "Pack")]
[string] $Action = "Build",
[Parameter(HelpMessage="The msbuild configuration to use.")]
[ValidateSet("Debug", "Release")]
[string] $Configuration = "Debug",
[switch] $SkipClean
)
function RunCommand {
param ([string] $CommandExpr)
Write-Verbose " $CommandExpr"
Invoke-Expression $CommandExpr
}
$rootDir = $PSScriptRoot
$srcDir = Join-Path -Path $rootDir -ChildPath 'src'
$testDir = Join-Path -Path $rootDir -ChildPath 'test'
$projectDir = Join-Path -Path $srcDir -ChildPath 'Donald'
if ($Action -eq "Test")
{
$projectdir = Join-Path -Path $testDir -ChildPath 'Donald.Tests'
}
if (!$SkipClean)
{
RunCommand "dotnet restore $projectDir --force --force-evaluate --nologo --verbosity quiet"
RunCommand "dotnet clean $projectDir -c $Configuration --nologo --verbosity quiet"
}
switch ($Action) {
"Test" { RunCommand "dotnet test `"$projectDir`"" }
"Pack" { RunCommand "dotnet pack `"$projectDir`" -c $Configuration --include-symbols --include-source" }
Default { RunCommand "dotnet build `"$projectDir`" -c $Configuration" }
}