@@ -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
178168Register-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" )
183171Invoke-WebRequest - Uri https:// www.nuget.org/ api/ v2/ package/ Bogus - OutFile (Join-Path $tempPath " bogus.zip" )
184172Invoke-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
1931777z x (Join-Path $tempPath " LumenWorksCsvReader.zip" ) " -o$ ( Join-Path $tempPath " LumenWorksCsvReader" ) " - y
1941787z 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
246182Write-Host " Copying Bogus.dll..." - ForegroundColor Green
@@ -279,59 +215,6 @@ if (-not $bogusCoreCopied) {
279215Copy-Item (Join-Path $tempPath " LumenWorksCsvReader/lib/net461/LumenWorks.Framework.IO.dll" ) - Destination (Join-Path $libPath " desktop/third-party/LumenWorks/LumenWorks.Framework.IO.dll" ) - Force
280216Copy-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
0 commit comments