Skip to content

Commit c6d816c

Browse files
Major update to v2025.7.19 - .NET 8 migration, improved assembly loading, and cross-platform enhancements (#18)
* Update .gitignore with new exclusions Removed docker-compose.yml from ignored files and added exclusions for OLDLIB, .devcontainer/.env, dbatools.library.zip, /artifacts, and .roo/mcp.json to better manage project artifacts and environment files. * Add devcontainer setup and AI Introduces .devcontainer configuration for development environments, including Dockerfile, docker-compose, environment example, PowerShell setup scripts, and workspace settings. Adds project metadata files such as .mcp.json, .claude/settings.local.json, .vscode.code-workspace, and CLAUDE.md for guidance and context. These changes enable standardized development, testing, and module management workflows. * Add preview release workflow and update build process Introduces a new build-release.yml workflow for building and publishing preview releases, including multi-platform build, artifact upload, and release creation. Updates build.yml to improve build steps, artifact handling, and verification, and switches to workflow_dispatch trigger for manual builds. * Refactor build scripts and add MSI install helper Replaces build-core.ps1, build-full.ps1, and build-local.ps1 with a unified build.ps1 script that centralizes build logic, artifact management, and dependency handling. Adds Wait-MsiInstall.ps1 to provide robust MSI installation waiting and error handling. This refactor streamlines the build process, improves maintainability, and ensures safer MSI package operations. * Update target frameworks and add publish profile Upgraded test project to target net472 and net8.0, updated global.json to use .NET SDK 8.0.*, and added a folder publish profile for dbatools. These changes modernize the project and enable publishing to a local folder. * Add DbaRenewableToken wrapper class Introduces DbaRenewableToken, a thin wrapper around IRenewableToken to facilitate token usage in Connect-DbaInstance. Supports construction from various token sources including SqlAuthenticationToken and PSObject. * Update target frameworks and package dependencies Upgraded target frameworks from net462/net6.0 to net472/net8.0. Updated and replaced several NuGet package references to newer versions, added Microsoft.AnalysisServices and System.Runtime.CompilerServices.Unsafe, and removed obsolete configuration blocks for ps3/ps4. Adjusted output paths and language version settings for improved compatibility and build output. * Update project configuration and dependencies (Claude minimal changes) Moved OutputPath, DocumentationFile, and LangVersion properties into configuration-specific PropertyGroups. Added new PropertyGroups for 'ps3' and 'ps4' configurations. Replaced System.Runtime.CompilerServices.Unsafe with System.Threading.Tasks.Dataflow in package references. * Update SQL Server and AnalysisServices DLLs Added new SQL Server related DLLs and updated several existing ones. Removed multiple Microsoft.AnalysisServices DLLs from both core and desktop directories, possibly reflecting a change in dependencies or supported features. * Simplify SqlClient and LumenWorks import logic Removed platform-specific win-sqlclient handling and macOS logic, as SqlClient is now directly in the lib folder. LumenWorks import is now explicit and not included in the names array. Updated Bogus import to use correct casing. * Update default dbatools branch in build workflow Changed the default branch for dbatools downloads from 'newver' to 'newestver' in the build-release GitHub Actions workflow. * Azure.Core - Update assembly list for PowerShell editions Reordered and added missing assemblies to the $names array for both Core and non-Core PowerShell editions. Ensures consistent loading of Azure and identity-related assemblies, and corrects duplication and ordering issues. * Add Azure.Core and Azure.Identity to assembly list Included 'Azure.Core' and 'Azure.Identity' in the list of assemblies for loading when not running on PowerShell Core. This may be required for new Azure-related functionality or dependencies. * Bump module version to 2025.7.19 Updated the ModuleVersion in dbatools.library.psd1 to reflect the new release version. * Refactor sqlpackage path detection in build workflow Simplifies and unifies the logic for locating sqlpackage executables across platforms in the build-release workflow. The new approach iterates over possible paths and provides improved error reporting and directory listing for troubleshooting. * Change sqlpackage error to warning in build workflow Replaces Write-Error with Write-Warning when sqlpackage is not found in the build-release workflow. This provides a less severe notification while still exiting with code 1. * Update sqlpackage not found warning in build workflow Refines the warning message when sqlpackage is not found and changes the directory listing to output full paths instead of just names. Removes the exit statement to prevent premature job termination. * Improve sqlpackage search in build workflow Refines the PowerShell command to recursively search for directories matching 'sqlpack' in the module path, making the sqlpackage lookup more accurate during the build-release workflow. * Fix sqlpackage path casing in build workflow Corrected the filename from 'sqlpackage.exe' to 'SqlPackage.exe' in the Windows path to ensure compatibility with case-sensitive file systems. * Update build workflow for core library artifacts Removes redundant Windows sqlpackage from core library as it matches the desktop version. Updates critical file verification to reflect this change by removing 'core\lib\dac\windows' and adding 'desktop\lib\dac'. * Update NuGet package versions in dbatools.csproj Upgraded Microsoft.Data.SqlClient to 6.0.2 and System.Threading.Tasks.Dataflow to 9.0.7 to ensure compatibility with latest features and bug fixes. * Add Microsoft.Bcl.AsyncInterfaces to DLL imports Included 'Microsoft.Bcl.AsyncInterfaces' in the list of DLLs imported for non-Core PowerShell editions to support async interfaces and improve compatibility. * Add System.Text.Json to required assemblies Included System.Text.Json in the list of assemblies loaded for non-Core PowerShell editions to support features that depend on JSON serialization. * Add Windows-specific GAC reference for net472 Introduced a conditional ItemGroup to reference System.Management.Automation from the GAC only when targeting net472 on Windows. This ensures proper assembly resolution in Windows environments. * Add PowerShell SDK reference for non-Windows net472 Adds a conditional PackageReference to PowerShellStandard.Library for net472 targets on non-Windows platforms to improve cross-platform compatibility. * Update sqlpackage paths in CI workflows Adjusted PowerShell scripts in build-release.yml and sqlpackage.yml to reference new sqlpackage locations for Windows, Linux, and Mac. Ensures correct executable is used for each platform and PowerShell edition. * Remove handling of 'private' directory from build scripts Eliminated references to the 'private' directory in GitHub workflow files and build.ps1. The creation and copying of the 'private' directory and its contents are no longer performed, streamlining the build process and artifact packaging. * Remove mcp.json configuration file Deleted the .roo/mcp.json file, which contained MCP server configuration for brave-search. This cleans up unused or obsolete configuration. * Remove sqlpackage GitHub Actions workflow Deleted the sqlpackage.yml workflow file from .github/workflows. This removes automated testing of sqlpackage across multiple platforms on pull requests.
1 parent 74aa271 commit c6d816c

16 files changed

+460
-246
lines changed

.claude/settings.local.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"model": "opus",
2+
"model": "sonnet",
33
"cleanupPeriodDays": 30,
4-
"dangerously-skip-permissions": true,
54
"permissions": {
65
"defaultMode": "bypassPermissions",
76
"allow": ["*"],

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
}
5353
},
5454
"terminal.integrated.shell.linux": "pwsh",
55-
"terminal.integrated.defaultProfile.linux": "pwsh"
55+
"terminal.integrated.defaultProfile.linux": "pwsh",
56+
"powershell.developer.editorServicesLogLevel": "Error",
57+
"powershell.integratedConsole.suppressStartupBanner": true
5658
},
5759
"extensions": [
5860
"ms-vscode.powershell",

.devcontainer/scripts/profile.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$env:POWERSHELL_UPDATECHECK = 'Off'

.github/workflows/build-release.yml

Lines changed: 92 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,32 @@ on:
2121
required: false
2222

2323
jobs:
24+
linux-build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Setup .NET
30+
uses: actions/setup-dotnet@v4
31+
with:
32+
dotnet-version: |
33+
8.0.x
34+
6.0.x
35+
36+
- name: Build core/lib
37+
shell: pwsh
38+
run: |
39+
./build/build.ps1 -CoreOnly
40+
41+
- name: Upload Linux artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: core-lib-linux
45+
path: artifacts/dbatools.library/core/lib/
46+
2447
build-windows:
2548
runs-on: windows-latest
49+
needs: linux-build
2650

2751
steps:
2852
- name: Checkout code
@@ -45,7 +69,23 @@ jobs:
4569
shell: pwsh
4670
run: |
4771
# Run the build script
48-
.\build\build.ps1
72+
.\build\build.ps1 -BuildZip
73+
74+
- name: Download Linux artifacts
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: core-lib-linux
78+
path: artifacts/core-lib-linux/
79+
80+
- name: Extract core-lib-linux artifact and copy to core/lib
81+
shell: pwsh
82+
run: Copy-Item -Path "artifacts/core-lib-linux/*" -Destination "artifacts/dbatools.library/core/lib" -Recurse -Force
83+
84+
- name: Ensure sqlpackage is executable
85+
shell: pwsh
86+
run: |
87+
chmod +x ./artifacts/dbatools.library/core/lib/dac/linux/sqlpackage
88+
chmod +x ./artifacts/dbatools.library/core/lib/dac/mac/sqlpackage
4989
5090
- name: Verify critical files and directories
5191
shell: pwsh
@@ -56,14 +96,13 @@ jobs:
5696
$criticalPaths = @(
5797
"desktop\lib",
5898
"desktop\lib\runtimes\win-x64\native",
99+
"core\lib\dac\windows",
59100
"desktop\third-party",
60101
"core\lib",
61102
"core\lib\runtimes\win-x64\native",
62-
"core\lib\dac\windows",
63103
"core\lib\dac\linux",
64104
"core\lib\dac\mac",
65-
"core\third-party",
66-
"private"
105+
"core\third-party"
67106
)
68107
69108
$missingPaths = @()
@@ -110,7 +149,7 @@ jobs:
110149
path: artifacts/dbatools.library.zip
111150

112151
test-sqlpackage:
113-
name: Test SqlPackage on ${{ matrix.os }}
152+
name: Test sqlpackage on ${{ matrix.os }}
114153
runs-on: ${{ matrix.os }}
115154
needs: build-windows
116155
strategy:
@@ -144,7 +183,7 @@ jobs:
144183
exit 1
145184
}
146185
147-
- name: Test SqlPackage
186+
- name: Test sqlpackage
148187
shell: pwsh
149188
run: |
150189
# Import the built module
@@ -158,71 +197,68 @@ jobs:
158197
Write-Host "Module loaded successfully with version: $($module.Version)"
159198
Write-Host "Module path: $($module.ModuleBase)"
160199
161-
# Determine SqlPackage path based on OS
200+
# Determine sqlpackage path based on OS
162201
$modulePath = $module.ModuleBase
163-
if ($IsWindows -or $PSVersionTable.PSVersion.Major -eq 5) {
164-
Write-Host "Testing Windows SqlPackage..."
165-
$dacPath = Join-Path $modulePath "core/lib/dac/windows"
166-
$sqlPackageName = "SqlPackage.exe"
167-
} elseif ($IsLinux) {
168-
Write-Host "Testing Linux SqlPackage..."
169-
$dacPath = Join-Path $modulePath "core/lib/dac/linux"
170-
$sqlPackageName = "SqlPackage"
171-
} elseif ($IsMacOS) {
172-
Write-Host "Testing macOS SqlPackage..."
173-
$dacPath = Join-Path $modulePath "core/lib/dac/mac"
174-
$sqlPackageName = "SqlPackage"
175-
} else {
176-
Write-Error "Unknown operating system"
177-
exit 1
178-
}
202+
$sqlPackageName = @(
203+
(Join-Path $modulePath "desktop/lib/dac/SqlPackage.exe"),
204+
(Join-Path $modulePath "core/lib/dac/windows/sqlpackage.exe"),
205+
(Join-Path $modulePath "core/lib/dac/linux/sqlpackage"),
206+
(Join-Path $modulePath "core/lib/dac/mac/sqlpackage")
207+
)
179208
180-
# Check if SqlPackage directory exists
181-
if (-not (Test-Path $dacPath)) {
182-
Write-Error "SqlPackage directory not found: $dacPath"
183-
Write-Host "Available directories in core/lib:"
184-
Get-ChildItem (Join-Path $modulePath "core/lib") -Directory | ForEach-Object { Write-Host " - $($_.Name)" }
185-
exit 1
209+
foreach ($sqlPackage in $sqlPackageName) {
210+
if (Test-Path $sqlPackage) {
211+
Write-Host "Found sqlpackage at: $sqlPackage"
212+
} else {
213+
Write-Warning "sqlpackage not found: $sqlPackage"
214+
Write-Host "Available directories in module"
215+
Get-ChildItem $modulePath -Recurse | Where-Object Name -match sqlpack | Select-Object Fullname
216+
}
186217
}
187218
188-
# Check if SqlPackage executable exists
189-
$sqlPackagePath = Join-Path $dacPath $sqlPackageName
190-
if (-not (Test-Path $sqlPackagePath)) {
191-
Write-Error "SqlPackage executable not found: $sqlPackagePath"
192-
Write-Host "Files in $dacPath :"
193-
Get-ChildItem $dacPath | ForEach-Object { Write-Host " - $($_.Name)" }
194-
exit 1
219+
$sqlPackagePath = if ($IsMacOS) {
220+
Join-Path $modulePath "core/lib/dac/mac/sqlpackage"
221+
} elseif ($IsLinux) {
222+
Join-Path $modulePath "core/lib/dac/linux/sqlpackage"
223+
} else {
224+
# if core then core
225+
if ($PSVersionTable.PSEdition -eq 'Core') {
226+
Join-Path $modulePath "core/lib/dac/windows/sqlpackage.exe"
227+
} else {
228+
# if desktop then desktop
229+
Join-Path $modulePath "desktop/lib/dac/SqlPackage.exe"
230+
}
195231
}
196232
197-
Write-Host "SqlPackage found at: $sqlPackagePath"
233+
Write-Host "Using sqlpackage at: $sqlPackagePath"
198234
199-
# Make SqlPackage executable on non-Windows platforms
235+
# Make sqlpackage executable on non-Windows platforms
200236
if ($IsLinux -or $IsMacOS) {
201237
chmod +x $sqlPackagePath
202238
}
203239
204-
# Test SqlPackage execution
240+
# Test sqlpackage execution
205241
try {
206-
Write-Host "Testing SqlPackage execution..."
242+
Write-Host "Testing sqlpackage execution..."
207243
$versionOutput = & $sqlPackagePath /Version 2>&1
208-
Write-Host "SqlPackage version: $versionOutput"
244+
Write-Host "sqlpackage version: $versionOutput"
209245
210246
# Basic functionality test - show help
211-
Write-Host "`nTesting SqlPackage help command..."
247+
Write-Host "`nTesting sqlpackage help command..."
212248
$helpOutput = & $sqlPackagePath /? 2>&1 | Select-Object -First 10
213249
$helpOutput | ForEach-Object { Write-Host $_ }
214250
Write-Host "... (output truncated)"
215251
216252
# Verify expected output from help
217253
$helpString = $helpOutput -join "`n"
218-
if ($helpString -match "Specifies a name value pair" -or $helpString -match "SqlPackage" -or $helpString -match "Command") {
219-
Write-Host "`nSqlPackage test completed successfully!"
254+
if ($helpString -match "Specifies a name value pair" -or $helpString -match "sqlpackage" -or $helpString -match "Command") {
255+
Write-Host "`nsqlpackage test completed successfully!"
220256
} else {
221-
Write-Error "SqlPackage help output does not contain expected content"
257+
Write-Error "sqlpackage help output does not contain expected content"
222258
exit 1
223259
}
224260
} catch {
225-
Write-Error "Failed to execute SqlPackage: $_"
261+
Write-Error "Failed to execute sqlpackage: $_"
226262
exit 1
227263
}
228264
@@ -252,7 +288,7 @@ jobs:
252288
}
253289
254290
# Download dbatools from GitHub
255-
$branch = "${{ github.event.inputs.dbatools_branch || 'newver' }}"
291+
$branch = "${{ github.event.inputs.dbatools_branch || 'newestver' }}"
256292
Write-Host "Downloading dbatools from GitHub (branch: $branch)..."
257293
258294
$zipUrl = "https://github.com/dataplat/dbatools/archive/refs/heads/$branch.zip"
@@ -309,17 +345,20 @@ jobs:
309345
Write-Host "Importing dbatools..."
310346
Import-Module dbatools -Force
311347
312-
Write-Host "Testing Get-DbaManagementObject..."
348+
Write-Host "Testing Connect-DbaInstance..."
313349
try {
314-
$result = Get-DbaManagementObject
315-
Write-Host "Test passed: Get-DbaManagementObject ran without fail"
350+
$result = Connect-DbaInstance -SqlInstance localhost
316351
} catch {
317-
Write-Error "Test failed with exception: $_"
318-
exit 1
352+
if ($PSItem.Exception.Message -notmatch "not accessible") {
353+
Write-Error "Test failed with exception: $_"
354+
exit 1
355+
} else {
356+
Write-Host "Test failed successfully (lol) with inaccessible instance message: $($PSItem.Exception.Message)" -ForegroundColor Green
357+
}
319358
}
320359
321360
create-preview-release:
322-
needs: [build-windows, test-sqlpackage]
361+
needs: [linux-build, build-windows, test-sqlpackage]
323362
runs-on: windows-latest
324363
# Create release if manually triggered OR if version contains "preview"
325364
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'

.github/workflows/build.yml

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,42 @@ defaults:
55
run:
66
shell: pwsh
77
jobs:
8-
# Linux tests are disabled - build-core.ps1 script not found
9-
# Keeping Windows build test only for now
8+
linux-build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Setup .NET
14+
uses: actions/setup-dotnet@v4
15+
with:
16+
dotnet-version: |
17+
8.0.x
18+
6.0.x
19+
20+
- name: Build core/lib
21+
shell: pwsh
22+
run: |
23+
./build/build.ps1 -CoreOnly
24+
25+
- name: Upload Linux artifacts
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: core-lib-linux
29+
path: artifacts/dbatools.library/core/lib/
30+
1031
windows-tests:
1132
runs-on: windows-latest
33+
needs: linux-build
1234

1335
steps:
1436
- uses: actions/checkout@v4
1537

38+
- name: Download Linux artifacts
39+
uses: actions/download-artifact@v4
40+
with:
41+
name: core-lib-linux
42+
path: artifacts/dbatools.library/core/lib/
43+
1644
- name: Setup .NET
1745
uses: actions/setup-dotnet@v4
1846
with:
@@ -31,6 +59,13 @@ jobs:
3159
run: |
3260
./build/build.ps1
3361
62+
- name: Copy Linux core/lib files
63+
shell: pwsh
64+
run: |
65+
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
68+
3469
- name: Verify critical files and directories
3570
shell: pwsh
3671
run: |
@@ -39,15 +74,14 @@ jobs:
3974
$artifactsDir = "./artifacts/dbatools.library"
4075
$criticalPaths = @(
4176
"desktop\lib",
77+
"desktop\lib\dac",
4278
"desktop\lib\runtimes\win-x64\native",
4379
"desktop\third-party",
4480
"core\lib",
4581
"core\lib\runtimes\win-x64\native",
46-
"core\lib\dac\windows",
4782
"core\lib\dac\linux",
4883
"core\lib\dac\mac",
49-
"core\third-party",
50-
"private"
84+
"core\third-party"
5185
)
5286
5387
$missingPaths = @()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ lib/
4040
.devcontainer/.env
4141
dbatools.library.zip
4242
/artifacts
43+
.roo/mcp.json

.roo/mcp.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

CLAUDE.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Get-DbatoolsLoadedAssembly
9191
1. **Clean**: Removes previous build artifacts
9292
2. **Compile**: Builds C# projects for both target frameworks
9393
3. **Package Dependencies**: Downloads and extracts:
94-
- SQL Server DacFramework (SqlPackage)
94+
- SQL Server DacFramework (sqlpackage)
9595
- Third-party NuGet packages (Bogus, LumenWorks CSV)
9696
- XESmartTarget for Extended Events
9797
4. **Platform Distribution**: Copies assemblies to appropriate platform directories
@@ -159,17 +159,20 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
159159
## Development Commands
160160

161161
### Testing
162+
163+
> **Note:** The following test commands reference Appveyor and Windows PowerShell scripts. For modern Linux/macOS/PowerShell Core setups or non-Appveyor CI, substitute with appropriate Pester/Invoke-Pester commands, and paths using forward slashes as needed.
164+
162165
```powershell
163-
# Run all tests
166+
# Run all tests (legacy, Windows/Appveyor)
164167
.\tests\appveyor.pester.ps1
165168
166-
# Run tests with code coverage
169+
# Run tests with code coverage (Windows/Appveyor)
167170
.\tests\appveyor.pester.ps1 -IncludeCoverage
168171
169-
# Run specific test file
172+
# Run specific test file (cross-platform)
170173
Invoke-Pester ./tests/Get-DbaDatabase.Tests.ps1
171174
172-
# Finalize test results
175+
# Finalize test results (Windows/Appveyor)
173176
.\tests\appveyor.pester.ps1 -Finalize
174177
```
175178

0 commit comments

Comments
 (0)