@@ -57,6 +57,23 @@ Synopsis: Build main binary module
5757#>
5858task BuildMainModule @binaryModuleParams {
5959 exec { dotnet publish - c $Configuration PSReadLine\PSReadLine.csproj }
60+
61+ # Restructure native SQLite DLLs from NuGet runtimes/{rid}/native/ into flat {rid}/ layout
62+ # that PowerShell's CorePsAssemblyLoadContext.NativeDllHandler expects.
63+ $publishPath = " PSReadLine/bin/$Configuration /$targetFramework /publish"
64+ $runtimesDir = Join-Path $publishPath ' runtimes'
65+ if (Test-Path $runtimesDir ) {
66+ Get-ChildItem $runtimesDir - Directory | ForEach-Object {
67+ $rid = $_.Name
68+ $nativeDir = Join-Path $_.FullName ' native'
69+ if (Test-Path $nativeDir ) {
70+ $dest = Join-Path $publishPath $rid
71+ New-Item - Path $dest - ItemType Directory - Force > $null
72+ Copy-Item (Join-Path $nativeDir ' *' ) $dest - Force
73+ }
74+ }
75+ Remove-Item $runtimesDir - Recurse - Force
76+ }
6077}
6178
6279<#
@@ -110,6 +127,31 @@ task LayoutModule BuildMainModule, {
110127 Copy-Item $binPath / Microsoft.PowerShell.PSReadLine.dll $targetDir
111128 Copy-Item $binPath / Microsoft.PowerShell.Pager.dll $targetDir
112129
130+ # Copy SQLite managed DLLs
131+ foreach ($dll in @ (
132+ ' Microsoft.Data.Sqlite.dll' ,
133+ ' SQLitePCLRaw.core.dll' ,
134+ ' SQLitePCLRaw.batteries_v2.dll' ,
135+ ' SQLitePCLRaw.provider.e_sqlite3.dll'
136+ )) {
137+ $dllPath = Join-Path $binPath $dll
138+ if (Test-Path $dllPath ) {
139+ Copy-Item $dllPath $targetDir
140+ }
141+ }
142+
143+ # Copy native SQLite DLLs in flat {rid}/ layout for PowerShell's NativeDllHandler
144+ foreach ($rid in @ (' win-x64' , ' win-x86' , ' win-arm' , ' win-arm64' , ' linux-x64' , ' linux-x86' , ' linux-arm' , ' linux-arm64' , ' linux-musl-x64' , ' linux-musl-arm64' , ' osx-x64' , ' osx-arm64' )) {
145+ $ridSource = Join-Path $binPath $rid
146+ if (Test-Path $ridSource ) {
147+ $ridDest = Join-Path $targetDir $rid
148+ if (-not (Test-Path $ridDest )) {
149+ New-Item $ridDest - ItemType Directory - Force > $null
150+ }
151+ Copy-Item " $ridSource /*" $ridDest - Force
152+ }
153+ }
154+
113155 if ($Configuration -eq ' Debug' ) {
114156 Copy-Item $binPath /* .pdb $targetDir
115157 }
0 commit comments