From 22b8af9d09a22140ae9db16d5b6025883ff1d1ef Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Tue, 23 Apr 2019 14:52:11 +0200
Subject: [PATCH] Be location-agnostic when creating / providing packages

---
 Scripts/Make-Package.ps1           | 10 +++++++++-
 Scripts/Provide-UpdaterPackage.ps1 |  8 ++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/Scripts/Make-Package.ps1 b/Scripts/Make-Package.ps1
index 4c4eb71..c74dd40 100644
--- a/Scripts/Make-Package.ps1
+++ b/Scripts/Make-Package.ps1
@@ -4,6 +4,11 @@
 # set our requirements:
 #Requires -version 5.1
 
+
+# Make sure to run from the directory containing the script itself:
+$BaseDir = $(Split-Path $MyInvocation.MyCommand.Path)
+Push-Location $BaseDir
+
 $ResourceDir = "..\Resources"
 
 
@@ -103,4 +108,7 @@ Write-Host
 
 Write-Host -NoNewline "Location: "
 Highlight "$(RelToAbs $PkgDir)"
-Write-Host
\ No newline at end of file
+Write-Host
+
+# Return to the original location before the script was called:
+Pop-Location
\ No newline at end of file
diff --git a/Scripts/Provide-UpdaterPackage.ps1 b/Scripts/Provide-UpdaterPackage.ps1
index e852ee7..dfb7f20 100644
--- a/Scripts/Provide-UpdaterPackage.ps1
+++ b/Scripts/Provide-UpdaterPackage.ps1
@@ -3,6 +3,7 @@ Param(
     [Parameter(Mandatory=$True)][String] $UpdaterSettings
 )
 
+
 try {
     . $UpdaterSettings
 }
@@ -13,6 +14,11 @@ catch {
 }
 
 
+# Make sure to run from the directory containing the script itself:
+$BaseDir = $(Split-Path $MyInvocation.MyCommand.Path)
+Push-Location $BaseDir
+
+
 $UpdateBinariesPath = "$($UpdateSourcePath)\Service\Binaries"
 
 $PackageDir = Get-ChildItem -Directory -Name |
@@ -41,3 +47,5 @@ catch {
     Exit
 }
 
+# Return to the original location before the script was called:
+Pop-Location
\ No newline at end of file
-- 
GitLab