diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml index b870ba34757c2..39e7d9b5c53ce 100644 --- a/eng/pipelines/common/global-build-job.yml +++ b/eng/pipelines/common/global-build-job.yml @@ -145,6 +145,9 @@ jobs: - ${{ each variable in parameters.variables }}: - ${{ variable }} steps: + - ${{ if eq(parameters.osGroup, 'windows') }}: + - template: /eng/pipelines/common/templates/disable-vsupdate-or-failfast.yml + - checkout: self clean: true # If running in source build mode, a git stash will be used for the inner clone. Avoid setting a fetch depth, diff --git a/eng/pipelines/common/templates/disable-vsupdate-or-failfast.yml b/eng/pipelines/common/templates/disable-vsupdate-or-failfast.yml new file mode 100644 index 0000000000000..7b9eab0bafdb5 --- /dev/null +++ b/eng/pipelines/common/templates/disable-vsupdate-or-failfast.yml @@ -0,0 +1,38 @@ +# This script tries to disable VSIXAutoUpdate. In case an update is seen as already running, +# it will exit with an error. +steps: + - powershell: | + schtasks /change /tn "\Microsoft\VisualStudio\VSIX Auto Update" /disable + + $vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" + if (-not (Test-Path -Path "$vswhere" -PathType Leaf)) + { + Write-Error "Couldn't locate vswhere at $vswhere" + exit 1 + } + + $vsdir = &"$vswhere" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath + $vsregedit = "$vsdir\Common7\IDE\VsRegEdit.exe" + + if (-not (Test-Path -Path "$vsregedit" )) + { + Write-Error "VSWhere returned path: $vsdir, but regedit $vsregedit doesn't exist." + exit 1 + } + + Write-Output "VSWhere returned path: $vsdir, using regedit $vsregedit" + Write-Output "Disabling updates through VS Registry:" + + &"$vsdir\Common7\IDE\VsRegEdit.exe" set local HKCU ExtensionManager AutomaticallyCheckForUpdates2Override dword 0 + &"$vsdir\Common7\IDE\VsRegEdit.exe" read local HKCU ExtensionManager AutomaticallyCheckForUpdates2Override dword + + $processes = Get-Process -Name VSIXAutoUpdate -ErrorAction SilentlyContinue + + if ($processes -ne $null -and $processes.Count -gt 0) + { + Write-Error "VSIXAutoUpdate has already spawned. Failfast to allow retry" + exit 1 + } + + displayName: Disable VSIX updates or fail-fast + condition: always() diff --git a/eng/pipelines/common/templates/runtimes/xplat-job.yml b/eng/pipelines/common/templates/runtimes/xplat-job.yml index 7249125648cf3..f4ac7e8295712 100644 --- a/eng/pipelines/common/templates/runtimes/xplat-job.yml +++ b/eng/pipelines/common/templates/runtimes/xplat-job.yml @@ -106,6 +106,9 @@ jobs: - ${{insert}}: ${{ variable }} steps: + - ${{ if eq(parameters.osGroup, 'windows') }}: + - template: /eng/pipelines/common/templates/disable-vsupdate-or-failfast.yml + - checkout: self clean: true fetchDepth: $(checkoutFetchDepth) diff --git a/eng/pipelines/installer/jobs/build-job.yml b/eng/pipelines/installer/jobs/build-job.yml index 04be011a54075..1d89cfad70eb2 100644 --- a/eng/pipelines/installer/jobs/build-job.yml +++ b/eng/pipelines/installer/jobs/build-job.yml @@ -293,6 +293,8 @@ jobs: parameters.archType, parameters.liveLibrariesBuildConfig) }} steps: + - ${{ if eq(parameters.osGroup, 'windows') }}: + - template: /eng/pipelines/common/templates/disable-vsupdate-or-failfast.yml - checkout: self clean: true fetchDepth: $(checkoutFetchDepth)