diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-08-25 23:25:41 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-08-25 23:25:41 -0700 |
| commit | 7a2a237e13da457bc672e27c03c492e128bdd11d (patch) | |
| tree | 5d3104164aded45c5d3a00c6e33f1bef7c4fbb20 | |
| parent | 3f88832110a780de991752323cf39b8f68b34c39 (diff) | |
| download | vcpkg-7a2a237e13da457bc672e27c03c492e128bdd11d.tar.gz vcpkg-7a2a237e13da457bc672e27c03c492e128bdd11d.zip | |
[vcpkg] Don't leak changes to the path in bootstrap
| -rw-r--r-- | scripts/bootstrap.ps1 | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 569bdbbc7..2dd6813a4 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -8,17 +8,25 @@ $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition $vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root Write-Verbose("vcpkg Path " + $vcpkgRootDir) -$env:path += ";$vcpkgRootDir\downloads\MinGit-2.14.1-32-bit\cmd" $gitHash = "unknownhash" -if (Get-Command "git" -ErrorAction SilentlyContinue) +$oldpath = $env:path +try { - $gitHash = git log HEAD -n 1 --format="%cd-%H" --date=short - if ($LASTEXITCODE -ne 0) + $env:path += ";$vcpkgRootDir\downloads\MinGit-2.14.1-32-bit\cmd" + if (Get-Command "git" -ListImported -ErrorAction SilentlyContinue) { - $gitHash = "unknownhash" + $gitHash = git log HEAD -n 1 --format="%cd-%H" --date=short + if ($LASTEXITCODE -ne 0) + { + $gitHash = "unknownhash" + } } } +finally +{ + $env:path = $oldpath +} Write-Verbose("Git repo version string is " + $gitHash) $vcpkgSourcesPath = "$vcpkgRootDir\toolsrc" @@ -27,7 +35,8 @@ if (!(Test-Path $vcpkgSourcesPath)) New-Item -ItemType directory -Path $vcpkgSourcesPath -force | Out-Null } -try{ +try +{ pushd $vcpkgSourcesPath $msbuildExeWithPlatformToolset = & $scriptsDir\findAnyMSBuildWithCppPlatformToolset.ps1 $msbuildExe = $msbuildExeWithPlatformToolset[0] @@ -40,6 +49,7 @@ try{ Copy-Item $vcpkgSourcesPath\Release\vcpkg.exe $vcpkgRootDir\vcpkg.exe | Out-Null Copy-Item $vcpkgSourcesPath\Release\vcpkgmetricsuploader.exe $vcpkgRootDir\scripts\vcpkgmetricsuploader.exe | Out-Null } -finally{ +finally +{ popd } |
