diff --git a/packages/golang-windows/packaging b/packages/golang-windows/packaging index e0a1e80b59..2193b6a9eb 100644 --- a/packages/golang-windows/packaging +++ b/packages/golang-windows/packaging @@ -1,28 +1,23 @@ . ./exiter.ps1 -try { - $BOSH_INSTALL_TARGET = Resolve-Path $env:BOSH_INSTALL_TARGET -} catch { - $Host.UI.WriteErrorLine($_.Exception.Message) - Exit 1 -} -$path="golang/go1.7.1.windows-amd64.zip" - -Add-Type -AssemblyName System.IO.Compression.FileSystem -function Unzip +$GOLANG_ZIP="golang/go1.7.1.windows-amd64.zip" +try { - param([string]$zipfile, [string]$outpath) + Add-Type -AssemblyName System.IO.Compression.FileSystem + function Unzip + { + param([string]$zipfile, [string]$outpath) - [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) -} + [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) + } -try -{ - Unzip $path ${BOSH_INSTALL_TARGET} + $BOSH_INSTALL_TARGET = Resolve-Path "${env:BOSH_INSTALL_TARGET}" + Unzip "$GOLANG_ZIP" "$BOSH_INSTALL_TARGET" } catch { - $Host.UI.WriteErrorLine($_.Exception.Message) + Write-Error "Error installing go:" + Write-Error $_.Exception.Message Exit 1 } Exit 0 diff --git a/packages/rep_windows/packaging b/packages/rep_windows/packaging index 16d3ce0603..f8fd332300 100644 --- a/packages/rep_windows/packaging +++ b/packages/rep_windows/packaging @@ -1,8 +1,9 @@ . ./exiter.ps1 + try { $BOSH_INSTALL_TARGET = Resolve-Path $env:BOSH_INSTALL_TARGET } catch { - $Host.UI.WriteErrorLine($_.Exception.Message) + Write-Error $_.Exception.Message Exit 1 } @@ -12,11 +13,6 @@ $env:PATH="${env:GOROOT}\bin;${env:PATH}" $pkg_name="rep" $pkg_path="code.cloudfoundry.org\rep\cmd\rep" -function CompileGo { - go.exe build -o "${BOSH_INSTALL_TARGET}\${pkg_name}.exe" "${pkg_path}" - $? -} - try { # Create GOPATH @@ -26,8 +22,9 @@ try Exit 1 } - if (-Not (CompileGo)) { - $Host.UI.WriteErrorLine("Error compiling: ${pkg_path}") + go.exe build -o "${BOSH_INSTALL_TARGET}\${pkg_name}.exe" "${pkg_path}" + if ($LASTEXITCODE -ne 0) { + Write-Error "Error compiling: ${pkg_path}" Exit 1 } @@ -36,7 +33,7 @@ try } catch { - $Host.UI.WriteErrorLine($_.Exception.Message) + Write-Error $_.Exception.Message Exit 1 }