Skip to content

Commit e1bc398

Browse files
Fix DAC (#24)
* Remove cross-platform sqlpackage and XESmartTarget handling Eliminated build steps, downloads, and directory creation for sqlpackage and XESmartTarget on Linux and macOS from build scripts and workflows. This simplifies the build process by focusing only on required components for Windows, removing unnecessary platform-specific logic and file verifications. * Add SqlPackage and XESmartTarget install step to CI Added a workflow step to install SqlPackage and XESmartTarget using dbatools commands before running DAC tests. This ensures required dependencies are available for the test suite. * Specify PowerShell shell for DAC test setup step Added 'shell: pwsh' to the 'Install SqlPackage and XESmartTarget for DAC tests' step to ensure the correct shell is used for running PowerShell commands. * Remove XESmartTarget install from build workflow The build-release GitHub Actions workflow no longer installs XESmartTarget during DAC tests, simplifying the setup. Also updates dbatools.library.psd1 module version to 2025.8.17.
1 parent 7c08c56 commit e1bc398

File tree

4 files changed

+8
-133
lines changed

4 files changed

+8
-133
lines changed

.github/workflows/build-release.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,16 @@ jobs:
7373
shell: pwsh
7474
run: .\build\build.ps1 -BuildZip
7575

76-
- name: Make sqlpackage executable
77-
if: runner.os != 'Windows'
78-
shell: pwsh
79-
run: |
80-
chmod +x ./artifacts/dbatools.library/core/lib/dac/linux/sqlpackage || true
81-
chmod +x ./artifacts/dbatools.library/core/lib/dac/mac/sqlpackage || true
82-
8376
- name: Verify critical files
8477
shell: pwsh
8578
run: |
8679
$artifactsDir = "./artifacts/dbatools.library"
8780
$criticalPaths = @(
8881
"desktop/lib",
8982
"desktop/lib/runtimes/win-x64/native",
90-
"core/lib/dac/windows",
9183
"desktop/third-party",
9284
"core/lib",
9385
"core/lib/runtimes/win-x64/native",
94-
"core/lib/dac/linux",
95-
"core/lib/dac/mac",
9686
"core/third-party"
9787
)
9888
@@ -211,6 +201,13 @@ jobs:
211201
New-Item -ItemType Directory -Path /tmp/DbatoolsExport -Force | Out-Null
212202
}
213203
204+
- name: Install SqlPackagetests
205+
shell: pwsh
206+
run: |
207+
Import-Module ./artifacts/dbatools.library/dbatools.library.psd1 -Force
208+
Import-Module ./dbatools/dbatools.psd1 -Force
209+
Install-DbaSqlPackage -Verbose
210+
214211
- name: Debug working directory
215212
shell: pwsh
216213
run: |

.github/workflows/build.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ jobs:
6363
shell: pwsh
6464
run: |
6565
Copy-Item -Path artifacts/core-lib-linux/* -Destination artifacts/dbatools.library/core/lib/ -Recurse -Force
66-
# delete windows sqlpackage on core cuz its the same as desktop
67-
Remove-Item -Path artifacts/dbatools.library/core/lib/dac/windows -Recurse -Force -ErrorAction Ignore
6866
6967
- name: Verify critical files and directories
7068
shell: pwsh
@@ -74,13 +72,10 @@ jobs:
7472
$artifactsDir = "./artifacts/dbatools.library"
7573
$criticalPaths = @(
7674
"desktop\lib",
77-
"desktop\lib\dac",
7875
"desktop\lib\runtimes\win-x64\native",
7976
"desktop\third-party",
8077
"core\lib",
8178
"core\lib\runtimes\win-x64\native",
82-
"core\lib\dac\linux",
83-
"core\lib\dac\mac",
8479
"core\third-party"
8580
)
8681

build/build.ps1

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -157,90 +157,26 @@ $tempdir = Join-Path ([System.IO.Path]::GetTempPath()) "dbatools-build"
157157

158158
# Create all required directories
159159
$null = New-Item -ItemType Directory $tempdir -Force -ErrorAction Ignore
160-
$null = New-Item -ItemType Directory (Join-Path $tempPath "dacfull") -Force -ErrorAction Ignore
161-
$null = New-Item -ItemType Directory (Join-Path $tempPath "xe") -Force -ErrorAction Ignore
162-
$null = New-Item -ItemType Directory (Join-Path $tempPath "linux") -Force -ErrorAction Ignore
163-
$null = New-Item -ItemType Directory (Join-Path $tempPath "mac") -Force -ErrorAction Ignore
164-
$null = New-Item -ItemType Directory (Join-Path $libPath "desktop/third-party/XESmartTarget") -Force
165160
$null = New-Item -ItemType Directory (Join-Path $libPath "desktop/third-party/bogus") -Force
166161
$null = New-Item -ItemType Directory (Join-Path $libPath "desktop/third-party/LumenWorks") -Force
167-
$null = New-Item -ItemType Directory (Join-Path $libPath "desktop/lib/dac") -Force
168-
$null = New-Item -ItemType Directory (Join-Path $libPath "core/lib/dac/windows") -Force
169-
$null = New-Item -ItemType Directory (Join-Path $libPath "core/third-party/XESmartTarget") -Force
170162
$null = New-Item -ItemType Directory (Join-Path $libPath "core/third-party/bogus") -Force
171163
$null = New-Item -ItemType Directory (Join-Path $libPath "core/third-party/LumenWorks") -Force
172-
$null = New-Item -ItemType Directory (Join-Path $libPath "core/lib/dac/mac") -Force
173-
$null = New-Item -ItemType Directory (Join-Path $libPath "core/lib/dac/linux") -Force
174164
$null = New-Item -ItemType Directory (Join-Path $libPath "core/lib/runtimes") -Force
175165
$null = New-Item -ItemType Directory (Join-Path $tempPath "bogus") -Force
176166
$null = New-Item -ItemType Directory (Join-Path $tempdir "nuget") -Force
177167

178168
Register-PackageSource -provider NuGet -name nugetRepository -Location https://www.nuget.org/api/v2 -Trusted -ErrorAction Ignore
179169

180170
# Download all required packages
181-
Invoke-WebRequest -Uri https://aka.ms/dacfx-msi -OutFile (Join-Path $tempPath "DacFramework.msi")
182-
Invoke-WebRequest -Uri https://aka.ms/sqlpackage-windows -OutFile (Join-Path $tempPath "sqlpackage-windows.zip")
183171
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Bogus -OutFile (Join-Path $tempPath "bogus.zip")
184172
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/LumenWorksCsvReader -OutFile (Join-Path $tempPath "LumenWorksCsvReader.zip")
185-
Invoke-WebRequest -Uri https://github.com/spaghettidba/XESmartTarget/releases/download/v1.5.7/XESmartTarget_x64.msi -OutFile (Join-Path $tempPath "XESmartTarget_x64.msi")
186-
Invoke-WebRequest -Uri https://github.com/spaghettidba/XESmartTarget/releases/download/2.0.4.0/XESmartTarget-linux-2.0.4.0.zip -OutFile (Join-Path $tempPath "XESmartTarget-linux.zip")
187-
Invoke-WebRequest -Uri https://aka.ms/sqlpackage-linux -OutFile (Join-Path $tempPath "sqlpackage-linux.zip")
188-
Invoke-WebRequest -Uri https://aka.ms/sqlpackage-macos -OutFile (Join-Path $tempPath "sqlpackage-macos.zip")
189173

190174
$ProgressPreference = "Continue"
191175

192176
# Extract all packages
193177
7z x (Join-Path $tempPath "LumenWorksCsvReader.zip") "-o$(Join-Path $tempPath "LumenWorksCsvReader")" -y
194178
7z x (Join-Path $tempPath "bogus.zip") "-o$(Join-Path $tempPath "bogus")" -y
195-
7z x (Join-Path $tempPath "XESmartTarget-linux.zip") "-o$(Join-Path $tempPath "xe-linux")" -y
196-
7z x (Join-Path $tempPath "sqlpackage-windows.zip") "-o$(Join-Path $tempPath "windows")" -y
197-
7z x (Join-Path $tempPath "sqlpackage-linux.zip") "-o$(Join-Path $tempPath "linux")" -y
198-
7z x (Join-Path $tempPath "sqlpackage-macos.zip") "-o$(Join-Path $tempPath "mac")" -y
199-
200-
# Install DacFramework MSI with proper waiting
201-
Write-Host "Installing DacFramework MSI..."
202-
$dacMsiPath = Resolve-Path (Join-Path $tempPath "DacFramework.msi")
203-
$dacTargetDir = Resolve-Path (Join-Path $tempPath "dacfull")
204-
$dacProcess = Start-Process -FilePath "msiexec.exe" -ArgumentList "/a", "`"$dacMsiPath`"", "/qb", "TARGETDIR=`"$dacTargetDir`"" -PassThru -Wait
205-
$dacExitCode = $dacProcess.ExitCode
206-
Write-Host "DacFramework MSI installation completed with exit code: $dacExitCode"
207-
if ($dacExitCode -ne 0) {
208-
Write-Warning "DacFramework MSI installation may have failed with exit code: $dacExitCode"
209-
}
210-
211-
# Small delay to ensure resources are released
212-
Start-Sleep -Seconds 2
213-
214-
# Install XESmartTarget MSI with proper waiting
215-
Write-Host "Installing XESmartTarget MSI..."
216-
$xeTargetDir = Resolve-Path (Join-Path $tempPath "xe")
217-
$xeMsiPath = Resolve-Path (Join-Path $tempPath "XESmartTarget_x64.msi")
218-
$xeProcess = Start-Process -FilePath "msiexec.exe" -ArgumentList "/a", "`"$xeMsiPath`"", "/qb", "TARGETDIR=`"$xeTargetDir`"" -PassThru -Wait
219-
$xeExitCode = $xeProcess.ExitCode
220-
Write-Host "XESmartTarget MSI installation completed with exit code: $xeExitCode"
221-
if ($xeExitCode -ne 0) {
222-
Write-Warning "XESmartTarget MSI installation may have failed with exit code: $xeExitCode"
223-
}
224-
225-
# Copy XESmartTarget preserving structure
226-
robocopy (Join-Path $tempPath "xe/XESmartTarget") (Join-Path $libPath "desktop/third-party/XESmartTarget") /E /NFL /NDL /NJH /NJS /nc /ns /np
227-
robocopy (Join-Path $tempPath "xe/XESmartTarget") (Join-Path $libPath "core/third-party/XESmartTarget") /E /NFL /NDL /NJH /NJS /nc /ns /np
228-
$robocopyExitCode = $LASTEXITCODE
229-
Write-Host "Robocopy exit code: $robocopyExitCode"
230-
if ($robocopyExitCode -ge 8) {
231-
Write-Host "Robocopy failed with exit code $robocopyExitCode" -ForegroundColor Red
232-
exit $robocopyExitCode
233-
} elseif ($robocopyExitCode -eq 0) {
234-
Write-Host "Robocopy: No files were copied (source and destination are in sync)" -ForegroundColor Yellow
235-
} else {
236-
Write-Host "Robocopy completed successfully (exit code $robocopyExitCode means files were copied)" -ForegroundColor Green
237-
}
238-
# Reset exit code to 0 for successful robocopy operations
239-
$LASTEXITCODE = 0
240179

241-
# Copy Linux XESmartTarget
242-
Copy-Item (Join-Path $tempPath "xe-linux/*") -Destination (Join-Path $libPath "desktop/third-party/XESmartTarget/") -Recurse -Force
243-
Copy-Item (Join-Path $tempPath "xe-linux/*") -Destination (Join-Path $libPath "core/third-party/XESmartTarget/") -Recurse -Force
244180

245181
# Copy Bogus files for both frameworks
246182
Write-Host "Copying Bogus.dll..." -ForegroundColor Green
@@ -279,59 +215,6 @@ if (-not $bogusCoreCopied) {
279215
Copy-Item (Join-Path $tempPath "LumenWorksCsvReader/lib/net461/LumenWorks.Framework.IO.dll") -Destination (Join-Path $libPath "desktop/third-party/LumenWorks/LumenWorks.Framework.IO.dll") -Force
280216
Copy-Item (Join-Path $tempPath "LumenWorksCsvReader/lib/netstandard2.0/LumenWorks.Framework.IO.dll") -Destination (Join-Path $libPath "core/third-party/LumenWorks/LumenWorks.Framework.IO.dll") -Force
281217

282-
# Copy ALL sqlpackage files for each platform
283-
Write-Host "Copying sqlpackage files for all platforms..." -ForegroundColor Green
284-
285-
# Windows - Copy ALL files from DAC bin directory to desktop/lib/dac (dacfx-msi)
286-
$dacPath = Join-Path (Join-Path $tempPath "dacfull") "Microsoft SQL Server\170\DAC\bin"
287-
if (Test-Path $dacPath) {
288-
Write-Host "Copying dacfx-msi files to desktop/lib/dac..." -ForegroundColor Green
289-
Copy-Item (Join-Path $dacPath "*") -Destination (Join-Path $libPath "desktop/lib/dac/") -Recurse -Force
290-
} else {
291-
Write-Warning "Windows DAC path not found: $dacPath"
292-
}
293-
294-
# Windows Core - Copy ALL files from sqlpackage Windows download to core/lib/dac/windows
295-
if (Test-Path (Join-Path $tempPath "windows")) {
296-
Write-Host "Copying sqlpackage Windows files to core/lib/dac/windows..." -ForegroundColor Green
297-
Copy-Item (Join-Path $tempPath "windows/*") -Destination (Join-Path $libPath "core/lib/dac/windows/") -Recurse -Force
298-
} else {
299-
Write-Warning "Windows sqlpackage path not found: $(Join-Path $tempPath "windows")"
300-
}
301-
302-
# Linux - Copy ALL files from temp/linux
303-
if (Test-Path (Join-Path $tempPath "linux")) {
304-
Write-Host "Copying ALL sqlpackage files for Linux..." -ForegroundColor Green
305-
Copy-Item (Join-Path $tempPath "linux/*") -Destination (Join-Path $libPath "core/lib/dac/linux/") -Recurse -Force
306-
# Ensure SqlPackage is renamed to sqlpackage (Linux is case-sensitive)
307-
$linSqlPackage = Join-Path $libPath "core/lib/dac/linux/SqlPackage"
308-
$finalname = Join-Path $libPath "core/lib/dac/linux/sqlpackage"
309-
$tempname = Join-Path $libPath "core/lib/dac/linux/sqlpackage-temp"
310-
311-
if (Test-Path $linSqlPackage) {
312-
Rename-Item $linSqlPackage $tempname
313-
Rename-Item $tempname $finalname
314-
}
315-
} else {
316-
Write-Warning "Linux sqlpackage path not found: $(Join-Path $tempPath "linux")"
317-
}
318-
319-
# macOS - Copy ALL files from temp/mac
320-
if (Test-Path (Join-Path $tempPath "mac")) {
321-
Write-Host "Copying ALL sqlpackage files for macOS..." -ForegroundColor Green
322-
Copy-Item (Join-Path $tempPath "mac/*") -Destination (Join-Path $libPath "core/lib/dac/mac/") -Recurse -Force
323-
# Ensure SqlPackage is renamed to sqlpackage (macOS case-sensitive too)
324-
$linSqlPackage = Join-Path $libPath "core/lib/dac/mac/SqlPackage"
325-
$finalname = Join-Path $libPath "core/lib/dac/mac/sqlpackage"
326-
$tempname = Join-Path $libPath "core/lib/dac/mac/sqlpackage-temp"
327-
328-
if (Test-Path $linSqlPackage) {
329-
Rename-Item $linSqlPackage $tempname
330-
Rename-Item $tempname $finalname
331-
}
332-
} else {
333-
Write-Warning "macOS sqlpackage path not found: $(Join-Path $tempPath "mac")"
334-
}
335218

336219
# Core files are already in place from dotnet publish
337220

dbatools.library.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
@{
99
# Version number of this module.
10-
ModuleVersion = '2025.8.5'
10+
ModuleVersion = '2025.8.17'
1111

1212
# ID used to uniquely identify this module
1313
GUID = '00b61a37-6c36-40d8-8865-ac0180288c84'

0 commit comments

Comments
 (0)