Skip to content

Commit c6820d1

Browse files
[windows] add SQL LocalDB warmup (actions#8435)
1 parent 2925b3a commit c6820d1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

images/win/scripts/Installers/Warmup-User.ps1

+17
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,22 @@ if (-not(Test-Path -Path $registryKeyPath)) {
2929
New-ItemProperty -Path $RegistryKeyPath -Name CacheType -PropertyType DWORD -Value 0
3030
reg.exe copy HKCU\Software\TortoiseSVN HKLM\DEFAULT\Software\TortoiseSVN /s
3131

32+
33+
# warmup SQL LocalDB
34+
# https://github.com/actions/runner-images/issues/8164
35+
36+
sqllocaldb create MSSQLLocalDB
37+
38+
$localDBInstance = Get-ChildItem -Path 'HKCU:\Software\Microsoft\Microsoft SQL Server\UserInstances'
39+
$instanceName = ($localDBInstance.Name).Split('\').where({ $true },'Last')
40+
$instancePath = 'HKCU:\Software\Microsoft\Microsoft SQL Server\UserInstances\' + $instanceName
41+
$dataDirectory = (Get-ItemProperty -Path $instancePath -Name 'DataDirectory').DataDirectory
42+
$localDBPath = 'C:\LocalDB'
43+
New-Item -ItemType 'Directory' -Path $localDBPath
44+
Move-Item -Path "$dataDirectory\*" -Destination $localDBPath
45+
Set-ItemProperty -Path $instancePath -Name 'DataDirectory' -Value $localDBPath
46+
47+
reg.exe copy 'HKCU\Software\Microsoft\Microsoft SQL Server' 'HKLM\DEFAULT\Software\Microsoft\Microsoft SQL Server' /s
48+
3249
reg.exe unload HKLM\DEFAULT
3350
Write-Host "Warmup-User.ps1 - completed"

0 commit comments

Comments
 (0)