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

pull/6/head
Mark McDowall 12 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'
@ -13,13 +12,19 @@ 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)
{ {
Remove-Item -Recurse -Force $outputFolder -ErrorAction Continue Remove-Item -Recurse -Force $outputFolder -ErrorAction Continue
} }
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
@ -72,14 +76,26 @@ 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

Loading…
Cancel
Save