Skip to content

Commit

Permalink
build script
Browse files Browse the repository at this point in the history
  • Loading branch information
pimbrouwers committed Aug 24, 2024
1 parent 47a8639 commit f3d0139
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[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] $NoRestore,

[switch] $Clean
)

function RunCommand {
param ([string] $CommandExpr)
Write-Verbose " $CommandExpr"
Invoke-Expression $CommandExpr
}

$projectName = "Danom"
$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 "$projectName.Tests" }
"Pack" { $projectDir = Join-Path -Path $srcDir -ChildPath "$projectName" }
Default { $projectDir = Join-Path -Path $srcDir -ChildPath "$projectName" }
}

if(!$NoRestore.IsPresent) {
RunCommand "dotnet restore $projectDir --force --force-evaluate --nologo --verbosity quiet"
}

if ($Clean)
{
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" }
}

0 comments on commit f3d0139

Please sign in to comment.