Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add base .net core support for xplatform/linux use #26

Merged
merged 4 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions PSSQLite/Invoke-SqliteQuery.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,25 @@

Try
{
Add-Type -TypeDefinition $cSharp -ReferencedAssemblies 'System.Data','System.Xml' -ErrorAction stop
if ($PSEdition -eq 'Core')
{
# Core doesn't auto-load these assemblies unlike desktop?
# Not csharp coder, unsure why
# by fffnite
$Ref = @(
'System.Data.Common'
'System.Management.Automation'
'System.ComponentModel.TypeConverter'
)
}
else
{
$Ref = @(
'System.Data'
'System.Xml'
)
}
Add-Type -TypeDefinition $cSharp -ReferencedAssemblies $Ref -ErrorAction stop
}
Catch
{
Expand Down Expand Up @@ -525,4 +543,4 @@
}
}
}
}
}
29 changes: 27 additions & 2 deletions PSSQLite/PSSQLite.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,33 @@
}

#Pick and import assemblies:
if([IntPtr]::size -eq 8) #64
if($PSEdition -eq 'core')
{
if($isLinux) {
write-verbose "loading linux-x64 core"
$SQLiteAssembly = Join-path $PSScriptRoot "core\linux-x64\System.Data.SQLite.dll"
}

if ($isMacOS) {
write-verbose "loading mac-x64 core"
$SQLiteAssembly = Join-path $PSScriptRoot "core\osx-x64\System.Data.SQLite.dll"
}

if ($isWindows) {
if([IntPtr]::size -eq 8) { #64
write-verbose "loading win-x64 core"
$SQLiteAssembly = Join-path $PSScriptRoot "core\win-x64\System.Data.SQLite.dll"
}
elseif([IntPtr]::size -eq 4) { #32
write-verbose "loading win-x32 core"
$SQLiteAssembly = Join-path $PSScriptRoot "core\win-x86\System.Data.SQLite.dll"
}
}
write-verbose -message "is PS Core, loading dotnet core dll"
}
elseif([IntPtr]::size -eq 8) #64
{
write-verbose -message "is x64, loading..."
$SQLiteAssembly = Join-path $PSScriptRoot "x64\System.Data.SQLite.dll"
}
elseif([IntPtr]::size -eq 4) #32
Expand Down Expand Up @@ -45,4 +70,4 @@
}

#Create some aliases, export public functions
Export-ModuleMember -Function $($Public | Select -ExpandProperty BaseName)
Export-ModuleMember -Function $($Public | Select -ExpandProperty BaseName)
44 changes: 44 additions & 0 deletions PSSQLite/Update-Sqlite.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function Update-Sqlite {
[CmdletBinding()]

param(
[Parameter()]
[string]
$version = '1.0.112',

[Parameter()]
[ValidateSet('linux-x64','osx-x64','win-x64','win-x86')]
[string]
$OS
)

Process {
write-verbose "Creating build directory"
New-Item -ItemType directory build
Set-Location build

$file = "system.data.sqlite.core.$version"

write-verbose "downloading files from nuget"
$dl = @{
uri = "https://www.nuget.org/api/v2/package/System.Data.SQLite.Core/$version"
outfile = "$file.nupkg"
}
Invoke-WebRequest @dl

write-verbose "unpacking and copying files to module directory"
Expand-Archive $dl.outfile

$InstallPath = (get-module PSSQlite).path.TrimEnd('PSSQLite.psm1')
copy-item $file/lib/netstandard2.0/System.Data.SQLite.dll $InstallPath/core/$os/
copy-item $file/runtimes/$os/native/netstandard2.0/SQLite.Interop.dll $InstallPath/core/$os/

write-verbose "removing build folder"
Set-location ..
remove-item ./build -recurse
write-verbose "complete"

Write-Warning "Please reimport the module to use the latest files"
}
}

Binary file added PSSQLite/core/linux-x64/SQLite.Interop.dll
Binary file not shown.
Binary file added PSSQLite/core/linux-x64/System.Data.SQLite.dll
Binary file not shown.
Binary file added PSSQLite/core/osx-x64/SQLite.Interop.dll
Binary file not shown.
Binary file added PSSQLite/core/osx-x64/System.Data.SQLite.dll
Binary file not shown.
Binary file added PSSQLite/core/win-x64/SQLite.Interop.dll
Binary file not shown.
Binary file added PSSQLite/core/win-x64/System.Data.SQLite.dll
Binary file not shown.
Binary file added PSSQLite/core/win-x86/SQLite.Interop.dll
Binary file not shown.
Binary file added PSSQLite/core/win-x86/System.Data.SQLite.dll
Binary file not shown.