Skip to content

Commit 6b25fb1

Browse files
fix for replication
1 parent 23220ab commit 6b25fb1

2 files changed

Lines changed: 59 additions & 19 deletions

File tree

private/assembly-lists.ps1

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,23 @@ $script:X64Assemblies = @(
4444
'Microsoft.SqlServer.Rmo'
4545
)
4646

47-
# Add x64-only assemblies if on 64-bit system
47+
# Add x64-only assemblies if on 64-bit system and Windows
4848
if ($env:PROCESSOR_ARCHITECTURE -ne "x86") {
49-
$script:CoreAssemblies += $script:X64Assemblies
49+
# Determine platform for replication assembly filtering
50+
$currentPlatform = if ($PSVersionTable.PSVersion.Major -ge 6) {
51+
if ($IsWindows) { 'Windows' }
52+
elseif ($IsLinux) { 'Linux' }
53+
else { 'OSX' }
54+
} else {
55+
'Windows' # PowerShell 5.1 and below only runs on Windows
56+
}
57+
58+
if ($currentPlatform -eq 'Windows') {
59+
$script:CoreAssemblies += $script:X64Assemblies
60+
} else {
61+
# On non-Windows platforms, only add Rmo (skip Replication)
62+
$script:CoreAssemblies += 'Microsoft.SqlServer.Rmo'
63+
}
5064
}
5165

5266
# Add Analysis Services assemblies if running under DSC
@@ -107,12 +121,23 @@ if ($PSVersionTable.PSEdition -ne "Core") {
107121
$script:AssemblyLoadOrder += 'Microsoft.SqlServer.Management.IntegrationServices'
108122
}
109123

110-
# Add x64-only assemblies if on 64-bit system
124+
# Add x64-only assemblies if on 64-bit system and Windows
111125
if ($env:PROCESSOR_ARCHITECTURE -ne "x86") {
112-
$script:AssemblyLoadOrder += @(
113-
'Microsoft.SqlServer.Replication',
114-
'Microsoft.SqlServer.Rmo'
115-
)
126+
# Determine platform for replication assembly filtering
127+
$currentPlatform = if ($PSVersionTable.PSVersion.Major -ge 6) {
128+
if ($IsWindows) { 'Windows' }
129+
elseif ($IsLinux) { 'Linux' }
130+
else { 'OSX' }
131+
} else {
132+
'Windows' # PowerShell 5.1 and below only runs on Windows
133+
}
134+
135+
if ($currentPlatform -eq 'Windows') {
136+
$script:AssemblyLoadOrder += @(
137+
'Microsoft.SqlServer.Replication',
138+
'Microsoft.SqlServer.Rmo'
139+
)
140+
}
116141
}
117142

118143
# Add Analysis Services assemblies to load order if running under DSC
@@ -198,21 +223,37 @@ $script:PlatformAssemblies = @{
198223
'Path' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
199224
'NativePath' = Join-Path $script:libraryroot "lib/core/runtimes/linux-x64/native"
200225
'Dependencies' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
226+
'ThirdParty' = @{
227+
'Bogus' = Join-Path $script:libraryroot "lib/third-party/bogus/core"
228+
'LumenWorks.Framework.IO' = Join-Path $script:libraryroot "lib/third-party/LumenWorks/core"
229+
}
201230
}
202231
'arm' = @{
203232
'Path' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
204233
'NativePath' = Join-Path $script:libraryroot "lib/core/runtimes/linux-arm/native"
205234
'Dependencies' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
235+
'ThirdParty' = @{
236+
'Bogus' = Join-Path $script:libraryroot "lib/third-party/bogus/core"
237+
'LumenWorks.Framework.IO' = Join-Path $script:libraryroot "lib/third-party/LumenWorks/core"
238+
}
206239
}
207240
'arm64' = @{
208241
'Path' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
209242
'NativePath' = Join-Path $script:libraryroot "lib/core/runtimes/linux-arm64/native"
210243
'Dependencies' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
244+
'ThirdParty' = @{
245+
'Bogus' = Join-Path $script:libraryroot "lib/third-party/bogus/core"
246+
'LumenWorks.Framework.IO' = Join-Path $script:libraryroot "lib/third-party/LumenWorks/core"
247+
}
211248
}
212249
'musl-x64' = @{
213250
'Path' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
214251
'NativePath' = Join-Path $script:libraryroot "lib/core/runtimes/linux-musl-x64/native"
215252
'Dependencies' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
253+
'ThirdParty' = @{
254+
'Bogus' = Join-Path $script:libraryroot "lib/third-party/bogus/core"
255+
'LumenWorks.Framework.IO' = Join-Path $script:libraryroot "lib/third-party/LumenWorks/core"
256+
}
216257
}
217258
'DAC' = Join-Path $script:libraryroot "lib/linux-dac"
218259
}
@@ -221,6 +262,10 @@ $script:PlatformAssemblies = @{
221262
'Path' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
222263
'NativePath' = Join-Path $script:libraryroot "lib/core/runtimes/osx/native"
223264
'Dependencies' = Join-Path $script:libraryroot "lib/core/runtimes/unix/lib/net6.0"
265+
'ThirdParty' = @{
266+
'Bogus' = Join-Path $script:libraryroot "lib/third-party/bogus/core"
267+
'LumenWorks.Framework.IO' = Join-Path $script:libraryroot "lib/third-party/LumenWorks/core"
268+
}
224269
}
225270
'DAC' = Join-Path $script:libraryroot "lib/mac-dac"
226271
}

private/assembly-resolution.ps1

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,15 @@ function Get-DbatoolsAssemblyPath {
137137
}
138138
elseif ($isThirdParty) {
139139
# Third-party assemblies use platform-specific paths
140-
if ($Platform -eq 'Windows') {
141-
$platformInfo = $script:PlatformAssemblies[$Platform][$Architecture]
142-
if (-not $platformInfo) {
143-
throw "Platform configuration not found for Windows $Architecture"
144-
}
145-
if (-not $platformInfo.ThirdParty -or -not $platformInfo.ThirdParty[$AssemblyName]) {
146-
throw "Third-party path not found for $AssemblyName"
147-
}
148-
$basePath = $platformInfo.ThirdParty[$AssemblyName]
149-
$assemblyPath = Join-Path $basePath "$AssemblyName.dll"
140+
$platformInfo = $script:PlatformAssemblies[$Platform][$Architecture]
141+
if (-not $platformInfo) {
142+
throw "Platform configuration not found for $Platform $Architecture"
150143
}
151-
else {
152-
throw "Third-party assemblies not supported on $Platform"
144+
if (-not $platformInfo.ThirdParty -or -not $platformInfo.ThirdParty[$AssemblyName]) {
145+
throw "Third-party path not found for $AssemblyName on $Platform $Architecture"
153146
}
147+
$basePath = $platformInfo.ThirdParty[$AssemblyName]
148+
$assemblyPath = Join-Path $basePath "$AssemblyName.dll"
154149
}
155150
else {
156151
# Common assemblies use runtime-specific paths

0 commit comments

Comments
 (0)