From f4c1883426f52cc897e33bf9520ff5333fc2b84c Mon Sep 17 00:00:00 2001 From: Moritz Maxeiner <mm@ucw.sh> Date: Sun, 25 Nov 2018 14:12:17 +0100 Subject: [PATCH] Add powershell library for common functions --- windows/Dockerfile | 1 + windows/lib.ps1 | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 windows/lib.ps1 diff --git a/windows/Dockerfile b/windows/Dockerfile index 2d5d566..699bc7b 100644 --- a/windows/Dockerfile +++ b/windows/Dockerfile @@ -121,3 +121,4 @@ RUN python -m pip --no-cache-dir install --no-warn-script-location \ numpy \ scipy \ pandas +COPY lib.ps1 C:/lib.ps1 diff --git a/windows/lib.ps1 b/windows/lib.ps1 new file mode 100644 index 0000000..efe2324 --- /dev/null +++ b/windows/lib.ps1 @@ -0,0 +1,28 @@ + +# +# Sets up Visual Studio Development environment +# +function VSDevEnv { + pushd "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools" + cmd /c "VsDevCmd.bat $args & set" | + foreach { + if ($_ -match "=") { + $v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])" + } + } + popd +} + +# +# Sets exit to error when the command fails +# +function Must-Run { + $command = $args[0] + $arguments = $args[1..($args.Length)] + & $command @arguments + if (!$?) { + $Host.SetShouldExit(1) + Write-Error "Exit code $LastExitCode while running $command $arguments" + Exit(1) + } +} -- GitLab