diff options
author | dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> | 2019-12-17 16:35:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-17 16:35:13 +0300 |
commit | 0b203829ede1f5495eabfb7505008cf31aeac222 (patch) | |
tree | 1b03b05fe0560729f98e5bb64f382f0085908707 /eng/common/tools.ps1 | |
parent | 5188f59922bce365093deac8d406831d8eea03ea (diff) |
Update dependencies from https://github.com/dotnet/arcade build 20191216.4 (#869)
- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19616.4
Diffstat (limited to 'eng/common/tools.ps1')
-rw-r--r-- | eng/common/tools.ps1 | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 09c3a3325..d3a432878 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -98,6 +98,9 @@ function Exec-Process([string]$command, [string]$commandArgs) { } } +# createSdkLocationFile parameter enables a file being generated under the toolset directory +# which writes the sdk's location into. This is only necessary for cmd --> powershell invocations +# as dot sourcing isn't possible. function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) { if (Test-Path variable:global:_DotNetInstallDir) { return $global:_DotNetInstallDir @@ -146,21 +149,23 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) { } $env:DOTNET_INSTALL_DIR = $dotnetRoot + } - if ($createSdkLocationFile) { - # Create a temporary file under the toolset dir and rename it to sdk.txt to avoid races. - do { - $sdkCacheFileTemp = Join-Path $ToolsetDir $([System.IO.Path]::GetRandomFileName()) - } - until (!(Test-Path $sdkCacheFileTemp)) - Set-Content -Path $sdkCacheFileTemp -Value $dotnetRoot - - try { - Rename-Item -Force -Path $sdkCacheFileTemp 'sdk.txt' - } catch { - # Somebody beat us - Remove-Item -Path $sdkCacheFileTemp - } + # Creates a temporary file under the toolset dir. + # The following code block is protecting against concurrent access so that this function can + # be called in parallel. + if ($createSdkLocationFile) { + do { + $sdkCacheFileTemp = Join-Path $ToolsetDir $([System.IO.Path]::GetRandomFileName()) + } + until (!(Test-Path $sdkCacheFileTemp)) + Set-Content -Path $sdkCacheFileTemp -Value $dotnetRoot + + try { + Rename-Item -Force -Path $sdkCacheFileTemp 'sdk.txt' + } catch { + # Somebody beat us + Remove-Item -Path $sdkCacheFileTemp } } |