Skip to content
Snippets Groups Projects
Commit c82d39f8 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Use Push-Location / Pop-Location instead of temporary variables

parent 22b8af9d
No related branches found
No related tags found
No related merge requests found
# 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
......@@ -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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment