-
Notifications
You must be signed in to change notification settings - Fork 3
/
Build.ps1
41 lines (34 loc) · 1.34 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
[CmdletBinding()]
param (
[Parameter(HelpMessage="The action to execute.")]
[ValidateSet("Build", "Test", "Pack", "Sln")]
[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'
switch ($Action) {
"Test" { $projectdir = Join-Path -Path $testDir -ChildPath 'Falco.Htmx.Tests' }
"Pack" { $projectDir = Join-Path -Path $srcDir -ChildPath 'Falco.Htmx' }
"Sln" { $projectDir = $rootDir }
Default { $projectDir = Join-Path -Path $srcDir -ChildPath 'Falco.Htmx' }
}
if (!$SkipClean.IsPresent)
{
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" }
}