Skip to content

Commit

Permalink
The build script restores dependencies, builds, and runs tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
plioi committed Jun 14, 2016
1 parent dc51291 commit 7072272
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Expand Up @@ -4,3 +4,5 @@
*.json text
*.txt text
*.md text
*.cmd text
*.ps1 text
3 changes: 3 additions & 0 deletions build.cmd
@@ -0,0 +1,3 @@
@echo off

powershell -NoProfile -ExecutionPolicy Bypass -Command "& '.\build.ps1' %*;"
45 changes: 45 additions & 0 deletions build.ps1
@@ -0,0 +1,45 @@
function main {
step { Restore }
step { Build }
step { Test }
}

function Restore {
exec { & dotnet restore --verbosity Warning }
}

function Build() {
exec { & dotnet build .\src\Parsley --configuration Release }
exec { & dotnet build .\src\Parsley.Tests --configuration Release }
}

function Test {
exec { & dotnet test .\src\Parsley.Tests --configuration Release }
}

function step($block) {
$name = $block.ToString().Trim().Split(' ')[0]
write-host "Executing $name" -fore CYAN
&$block
}

function exec($cmd) {
$global:lastexitcode = 0
& $cmd
if ($lastexitcode -ne 0) {
throw "Error executing command:$cmd"
}
}

try {
main
write-host
write-host "Build Succeeded!" -fore GREEN
exit 0
} catch [Exception] {
write-host
write-host $_.Exception.Message -fore DARKRED
write-host
write-host "Build Failed!" -fore DARKRED
exit 1
}

0 comments on commit 7072272

Please sign in to comment.