Skip to content

Commit 11d50a0

Browse files
authored
Fix concurrent vsixFile download in New-BcCompilerFolder (#3391)
Fixes a concurrency issue when multiple processes try to use New-BcCompilerFolder with the -vsixFile Parameter ## Problem Description We use multiple build agents on our build server(s). In high concurrency scenarios like parallel build stages we encounter locking issues when multiple builds try to download the vsix file, because all processes try to save the vsix-tempfile to the same location. ``` Using https://ms-dynamics-smb.gallerycdn.vsassets.io/extensions/ms-dynamics-smb/al/12.6.936426/1707296229269/Microsoft.VisualStudio.Services.VSIXPackage New-BcCompilerFolder Telemetry Correlation Id: d40bb062-056f-4a96-a47c-8cbee117ac0b ##[error]Remove-Item : Cannot remove item C:\Users\TfsBuild\AppData\Local\Temp\alc.zip: The process cannot access the file 'C:\Users\TfsBuild\AppData\Local\Temp\alc.zip' because it is being used by another process. ``` ## Solution Description By adding the `$containerName` to the temp file name the issue should be resolved. Name does not matter anyway because it is just a tempfile.
1 parent 55e6b31 commit 11d50a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CompilerFolderHandling/New-BcCompilerFolder.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ try {
186186
if ($vsixFile) {
187187
# If a vsix file was specified unpack directly to compilerfolder
188188
Write-Host "Using $vsixFile"
189-
$tempZip = Join-Path ([System.IO.Path]::GetTempPath()) "alc.zip"
189+
$tempZip = Join-Path ([System.IO.Path]::GetTempPath()) "alc.$containerName.zip"
190190
Download-File -sourceUrl $vsixFile -destinationFile $tempZip
191191
Expand-7zipArchive -Path $tempZip -DestinationPath $containerCompilerPath
192192
if ($isWindows -and $newtonSoftDllPath) {

0 commit comments

Comments
 (0)