diff --git a/Scripts/Install-NewestPackage.ps1 b/Scripts/Install-NewestPackage.ps1 index ff3b07e3feb70cc5f2c599090624ba3279979291..8e492636e514d2a1a6462af59cba36e2ba5d4b84 100644 --- a/Scripts/Install-NewestPackage.ps1 +++ b/Scripts/Install-NewestPackage.ps1 @@ -1,9 +1,13 @@ +# Make sure to run from the directory containing the script itself: +$BaseDir = $(Split-Path $MyInvocation.MyCommand.Path) +Push-Location $BaseDir + + $PackageDir = Get-ChildItem -Directory -Name | Where-Object {$_ -match 'build_[0-9]{4}-[0-9]{2}-[0-9]{2}_'} | Sort-Object | Select-Object -Last 1 -$CurDir = Get-Location Write-Host -NoNewLine "Installing package [" Write-Host -NoNewLine $PackageDir -Fore Green @@ -13,4 +17,5 @@ Write-Host "" cd $PackageDir ./Install-Service.ps1 -cd $CurDir \ No newline at end of file +# Return to the original location before the script was called: +Pop-Location \ No newline at end of file diff --git a/Scripts/Prepare-Build.ps1 b/Scripts/Prepare-Build.ps1 index 1a10898d164ed369d8ca29e21f36b42ff2e6f1fe..05ce5a1a17d1d5ae8183d7a138895bf6506b4ca0 100644 --- a/Scripts/Prepare-Build.ps1 +++ b/Scripts/Prepare-Build.ps1 @@ -79,8 +79,7 @@ function Parse-GitDescribe([string]$CommitName) { $ErrorActionPreference = "Stop" -$OldLocation = Get-Location -Set-Location $SolutionDir -ErrorAction Stop +Push-Location $SolutionDir -ErrorAction Stop $BCommit = "$($SolutionDir)\Resources\BuildCommit.txt" $BuildDate = "$($SolutionDir)\Resources\BuildDate.txt" @@ -141,4 +140,4 @@ Write-Output $( Write-BuildDetails $BuildDetailsCS $DescItems $GitBranch $DateShort -Set-Location $OldLocation \ No newline at end of file +Pop-Location \ No newline at end of file diff --git a/Scripts/Uninstall-Service.ps1 b/Scripts/Uninstall-Service.ps1 index aec6cbd35bcf5bc4d6b87190eb51c7482a2417fe..fa954b52df820a299964646534f49103760cf4d7 100644 --- a/Scripts/Uninstall-Service.ps1 +++ b/Scripts/Uninstall-Service.ps1 @@ -9,11 +9,9 @@ Write-Host "Loaded configuration '$LocalConfiguration'." -Fore Green Write-Host $ServiceDir Write-Host $SourceDir -$CurDir = Get-Location - -Set-Location "C:\Windows\Microsoft.NET\Framework\v4.0.30319" +Push-Location "C:\Windows\Microsoft.NET\Framework\v4.0.30319" $ServiceExe = $ServiceDir + "\" + $ServiceName + ".exe" .\InstallUtil.exe -u $ServiceExe -Set-Location $CurDir \ No newline at end of file +Pop-Location \ No newline at end of file