Exit with non-zero exit code when build.ps1 fails

pull/4/head
Mark McDowall 11 years ago
parent f4ceb57b2b
commit b79f695564

@ -2,7 +2,6 @@ param (
[switch]$runTests = $false [switch]$runTests = $false
) )
$msBuild = 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe' $msBuild = 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe'
$outputFolder = '.\_output' $outputFolder = '.\_output'
$testSearchPattern = '*.Test\bin\x86\Release' $testSearchPattern = '*.Test\bin\x86\Release'
@ -12,6 +11,8 @@ Function Build()
{ {
$clean = $msbuild + " nzbdrone.sln /t:Clean /m" $clean = $msbuild + " nzbdrone.sln /t:Clean /m"
$build = $msbuild + " nzbdrone.sln /p:Configuration=Release /p:Platform=x86 /t:Build /m" $build = $msbuild + " nzbdrone.sln /p:Configuration=Release /p:Platform=x86 /t:Build /m"
if(Test-Path $outputFolder) if(Test-Path $outputFolder)
{ {
@ -19,7 +20,11 @@ Function Build()
} }
Invoke-Expression $clean Invoke-Expression $clean
CheckExitCode
Invoke-Expression $build Invoke-Expression $build
CheckExitCode
CleanFolder $outputFolder CleanFolder $outputFolder
} }
@ -42,7 +47,7 @@ Function CleanFolder($path)
Function PackageTests() Function PackageTests()
{ {
Write-Host Packagin Tests Write-Host Packaging Tests
if(Test-Path $testPackageFolder) if(Test-Path $testPackageFolder)
{ {
@ -60,7 +65,6 @@ Function PackageTests()
} }
Function Nunit() Function Nunit()
{ {
$testFiles $testFiles
@ -71,15 +75,27 @@ Function Nunit()
} }
$nunitExe = '.\Libraries\nunit\nunit-console-x86.exe ' + $testFiles + ' /process:multiple /noxml' $nunitExe = '.\Libraries\nunit\nunit-console-x86.exe ' + $testFiles + ' /process:multiple /noxml'
Invoke-Expression $nunitExe Invoke-Expression $nunitExe
CheckExitCode
} }
Function RunGrunt() Function RunGrunt()
{ {
$gruntPath = [environment]::getfolderpath("applicationdata") + '\npm\node_modules\grunt-cli\bin\grunt' $gruntPath = [environment]::getfolderpath("applicationdata") + '\npm\node_modules\grunt-cli\bin\grunt'
Invoke-Expression 'npm install' Invoke-Expression 'npm install'
CheckExitCode
Invoke-Expression ('node ' + $gruntPath + ' package') Invoke-Expression ('node ' + $gruntPath + ' package')
CheckExitCode
}
Function CheckExitCode()
{
if ($lastexitcode -ne 0)
{
Write-Host $errorMessage
exit 1
}
} }
Build Build
@ -89,4 +105,4 @@ PackageTests
if($runTests) if($runTests)
{ {
Nunit Nunit
} }

Loading…
Cancel
Save