diff --git a/eng/helix/content/mssql/InstallSqlServerLocalDB.ps1 b/eng/helix/content/mssql/InstallSqlServerLocalDB.ps1 index f4c5995f70..5af8fc5dac 100644 --- a/eng/helix/content/mssql/InstallSqlServerLocalDB.ps1 +++ b/eng/helix/content/mssql/InstallSqlServerLocalDB.ps1 @@ -7,7 +7,9 @@ https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-2016-express-localdb?view=sql-server-2016 https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-2016 #> - +param( + [switch]$Force +) $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138 Set-StrictMode -Version 1 @@ -15,6 +17,11 @@ Set-StrictMode -Version 1 $intermedateDir = "$PSScriptRoot\obj" mkdir $intermedateDir -ErrorAction Ignore | Out-Null +if (-not $Force -and (Test-Path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\RefCount\SqlLocalDB13')) { + Write-Host "SQL Server 2016 Express LocalDB is already installed. Exiting without action. Call this script again with -Force to run the installation anyways." + exit 0 +} + Write-Host "Installing SQL Server 2016 Express LocalDB" -f Magenta # Download SqlLocalDB.msi. diff --git a/eng/targets/Helix.Common.props b/eng/targets/Helix.Common.props index 6f66e101d1..f4cd02ece0 100644 --- a/eng/targets/Helix.Common.props +++ b/eng/targets/Helix.Common.props @@ -33,8 +33,7 @@ - - +