Powershell: Question: How to import SQLite library

Created on 28 Jan 2018  路  12Comments  路  Source: PowerShell/PowerShell

Goal

Use SQLite with PowerShell 6. I have used SQLite with .NET Core so it seems like this should be possible. I have been using SQLite with PowerShell 5 for quite some time.

Attempt 1

Install SQLite package from nuget.

PS C:\Users\egagn\Desktop> Install-Package Microsoft.Data.Sqlite -Version 2.1.0-preview1-28181 -Source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Install-Package : Unable to find package source 'https://dotnet.myget.org/F/dotnet-core/api/v3/index.json'. Use Get-PackageSource to see all available package sources.
At line:1 char:1
+ Install-Package Microsoft.Data.Sqlite -Version 2.1.0-preview1-28181 - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Attempt 2

Build Microsoft.Data.Sqlite from source.

C:\Users\egagn\Desktop> git clone https://github.com/aspnet/Microsoft.Data.Sqlite
Cloning into 'Microsoft.Data.Sqlite'...
remote: Counting objects: 4080, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 4080 (delta 4), reused 11 (delta 3), pack-reused 4059
Receiving objects: 100% (4080/4080), 981.42 KiB | 1.18 MiB/s, done.
Resolving deltas: 100% (2576/2576), done.
C:\Users\egagn\Desktop> cd Microsoft.Data.Sqlite
C:\Users\egagn\Desktop> build.cmd
Downloading KoreBuild 2.1.0-preview1-15670
Using KoreBuild 2.1.0-preview1-15670
...
Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:03:07.61
C:\Users\egagn\Desktop> $SQLiteDLL = "C:\Users\egagn\Desktop\Microsoft.Data.Sqlite\src\Microsoft.Data.Sqlite\bin\Debug\netstandard2.0\Microsoft.Data.Sqlite.dll"
C:\Users\egagn\Desktop> [Reflection.Assembly]::LoadFile($SQLiteDLL)


GAC    Version        Location
---    -------        --------
False  v4.0.30319     C:\Users\egagn\Desktop\Microsoft.Data.Sqlite\src\Microsoft.Data.Sqlite\bin\Debug\netstandard2.0\Microsoft.Data.Sqlite.dll


PS C:\Users\egagn\Desktop> $Connection = New-Object -TypeName Microsoft.Data.Sqlite.SqliteConnection("Data Source=Sample.db")
New-Object : Cannot find type [Microsoft.Data.Sqlite.SqliteConnection]: verify that the assembly containing this type is loaded.
At line:1 char:15
+ ... onnection = New-Object -TypeName Microsoft.Data.Sqlite.SqliteConnecti ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

PS C:\Users\egagn\Desktop> [appdomain]::CurrentDomain.GetAssemblies() | ? fullname -match 'Microsoft.Data.Sqlite' | % { $_.GetExportedTypes() }
PS C:\Users\egagn\Desktop>

Attempt 3

Use .NET Framework (.NET v4) DLL.

PS C:\Users\egagn\Desktop> [Reflection.Assembly]::LoadFile("C:\dartbox\Utilities\DLL_Library\SQLite\System.Data.SQLite.dll")

GAC    Version        Location
---    -------        --------
False  v4.0.30319     C:\dartbox\Utilities\DLL_Library\SQLite\System.Data.SQLite.dll


PS C:\Users\egagn\Desktop> $Connection = New-Object -TypeName System.Data.SQLite.SQLiteConnection
PS C:\Users\egagn\Desktop> $Connection.ConnectionString = "Data Source=C:\dartbox\Documents\Configuration\PSConfig\Data\vault.db"
PS C:\Users\egagn\Desktop> $Connection.Open()

# CRASH! PowerShell Core 6 has stopped working

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.1
PSEdition                      Core
GitCommitId                    v6.0.1
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Question Resolution-External

Most helpful comment

I was able to get it working. First I tried a fresh VM and it worked the first time. Had to run Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2)

Then I went back to my laptop. I was able to get it working by simply doing:

Unregister-PackageSource Nuget
Unregister-PackageSource Nuget.org
Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2

# Close PowerShell, re-open PowerShell

Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0 -Scope CurrentUser -Verbose

After that, I found all the packages under C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages.

Now I'd like to import the package and use it. Here's my attempt:

PS C:\Users\egagn> $Packages = "C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages"                                                                                                  
PS C:\Users\egagn> [Reflection.Assembly]::LoadFile("$Packages\Microsoft.Data.Sqlite.Core.2.0.0\lib\netstandard2.0\Microsoft.Data.Sqlite.dll")                                                   

GAC    Version        Location                                                                                                                                                                  
---    -------        --------                                                                                                                                                                  
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\Microsoft.Data.Sqlite.Core.2.0.0\lib\netstandard2.0\Microsoft.Data.Sqlite.dll                               


PS C:\Users\egagn>                                                                                                                                                                              
PS C:\Users\egagn> # Not sure which one is needed, just import them all                                                                                                                         
PS C:\Users\egagn> $Targets = @("MonoAndroid","net35","net40","net45","netstandard1.0","netstandard1.1","portable-net40+sl5+netcore45+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10","portable-net
45+netcore45+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10","portable-net45+netcore45+wpa81+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10","uap10.0","win8","win81","wpa81","Xamarin.iOS10","Xamar
in.Mac20")                                                                                                                                                                                      
PS C:\Users\egagn> foreach($t in $Targets) {                                                                                                                                                    
>>     [Reflection.Assembly]::LoadFile("$Packages\SQLitePCLRaw.core.1.1.9\lib\$t\SQLitePCLRaw.core.dll")                                                                                        
>> }                                                                                                                                                                                            

GAC    Version        Location                                                                                                                                                                  
---    -------        --------                                                                                                                                                                  
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\MonoAndroid\SQLitePCLRaw.core.dll                                               
False  v2.0.50727     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\net35\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\net40\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\net45\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\netstandard1.0\SQLitePCLRaw.core.dll                                            
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\netstandard1.1\SQLitePCLRaw.core.dll                                            
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\portable-net40+sl5+netcore45+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQL... 
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\portable-net45+netcore45+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLit... 
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\S... 
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\uap10.0\SQLitePCLRaw.core.dll                                                   
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\win8\SQLitePCLRaw.core.dll                                                      
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\win81\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\wpa81\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\Xamarin.iOS10\SQLitePCLRaw.core.dll                                             
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\Xamarin.Mac20\SQLitePCLRaw.core.dll                                             


PS C:\Users\egagn>                                                                                                                                                                              
PS C:\Users\egagn> $Connection = New-Object -TypeName Microsoft.Data.SQLite.SQLiteConnection                                                                                                    
PS C:\Users\egagn> $Connection.ConnectionString = "Data Source=C:\vault.db"                                                                                                                     
The following exception occurred while retrieving member "ConnectionString": "Could not load file or assembly 'SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab
535'. The system cannot find the file specified."                                                                                                                                               
At line:1 char:1                                                                                                                                                                                
+ $Connection.ConnectionString = "Data Source=C:\vault.db"                                                                                                                                      
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                      
+ CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException                                                                                                                     
+ FullyQualifiedErrorId : CatchFromBaseGetMember                                                                                                                                                

PS C:\Users\egagn>                                                                                                                                                                              

Oh well, I don't expect you to solve all my problems so I'm happy to close this ticket anytime you see fit. It does seem like I'm trying to do something that just isn't easy yet.

All 12 comments

More like this issue has been mention before that NuGet mostly are for Windows full .NET. But, while writing this comment, I found the .NETCore version:
https://www.nuget.org/packages/Microsoft.Data.Sqlite.Core/

Try it an see if it works with the Microsoft.Data.Sqlite.Core v2.0.0. The one previously use is only for Windows.

NuGet site need to start providing more information and tag properly their packages: OS Type, .Net Full, and/or .NET Core.

:)

Thanks. Here's how things are going:

PS C:\Users\egagn> Install-Package Microsoft.Data.Sqlite.Core -Version 2.0.0
Install-Package : A parameter cannot be found that matches parameter name 'Version'.
At line:1 char:44
+ Install-Package Microsoft.Data.Sqlite.Core -Version 2.0.0
+                                            ~~~~~~~~
+ CategoryInfo          : InvalidArgument: (:) [Install-Package], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
PS C:\Users\egagn> Install-Package Microsoft.Data.Sqlite.Core
Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Data.Sqlite.Core'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Microsoft.Data.Sqlite.Core
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage



md5-995e6a43bdbcfb764573588c746270af



PS C:\Users\egagn> Install-Package Microsoft.Data.Sqlite
Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Data.Sqlite'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Microsoft.Data.Sqlite
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage



md5-627513af198294c3e62474d1bd8b6684



PS C:\Users\egagn> Import-Module SQLite
ipmo : Could not load file or assembly 'C:\Users\egagn\OneDrive\Documents\PowerShell\Modules\SQLite\2.0\bin\System.Data.SQLite.dll'. Format of the executable (.exe) or library (.dll) is invalid.
At C:\Users\egagn\OneDrive\Documents\PowerShell\Modules\SQLite\2.0\start-sqlite.psm1:89 char:30
+ ls $PSScriptRoot/bin/*.dll | ipmo;
+                              ~~~~
+ CategoryInfo          : NotSpecified: (:) [Import-Module], BadImageFormatException
+ FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand

@elijahgagne,

Wrong command line as parameter -Version doesn't exist. Use the following:

Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0

Also, make use to Open PSCore6 "as an Administrator" before installing Module(s)/Package(s).

Hope this helps!

Thanks for the continued help. No luck so far:

PS C:\Users\egagn> Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0 -Verbose
VERBOSE: Using the provider 'NuGet' for searching packages.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Searching repository 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://dartmouth.myget.org/F/aig/auth/0bc6ec80-5fcf-42e3-9a3a-c862e1a70b65/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://dartmouth.myget.org/F/aig/auth/0bc6ec80-5fcf-42e3-9a3a-c862e1a70b65/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'Microsoft.Data.Sqlite.Core'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'Microsoft.Data.Sqlite.Core'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://dartmouth.myget.org/F/dba/auth/0bc6ec80-5fcf-42e3-9a3a-c862e1a70b65/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://dartmouth.myget.org/F/dba/auth/0bc6ec80-5fcf-42e3-9a3a-c862e1a70b65/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'Microsoft.Data.Sqlite.Core'.
Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Data.Sqlite.Core'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0 -Ve ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

PS C:\Users\egagn>

Hum! OK... I just duplicated the error on a VM that I'm using for testing fresh PSCore install/uninstall.
I got one machine good but the VM fails.

Let get back to you!

@elijahgagne

Got it!! As I mention I've been testing clean install/uninstall of PSCore then I caught the following issue.
I had NuGet previously registered, but if I uninstalled PSCore then I have to remember to register NuGet again.

Please, try executing code function "Verify-NuGetRegistered" to verify that you got NuGet registered before doing any package installation(s):

function Verify-NugetRegistered
{
    [CmdletBinding()]
    Param ()
    # Microsoft provided code:
    # Register NuGet package source, if needed
    # The package source may not be available on some systems (e.g. Linux/Windows)
    if (-not (Get-PackageSource | Where-Object{ $_.Name -eq 'Nuget' }))
    {
        Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2
    }
    else
    {
        Write-Host "NuGet Already Exist! No Need to install."
    };
};

## - Execute:
Verify-NugetRegistered

I got it working again on my VM test.

nuget_register_01_2018-01-29_10-09-22

Very nice! But for some reason I'm still having trouble:

PowerShell v6.0.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\Users\egagn> function Verify-NugetRegistered
>> {
>> [CmdletBinding()]
>> Param ()
>> # Microsoft provided code:
>> # Register NuGet package source, if needed
>> # The package source may not be available on some systems (e.g. Linux/Windows)
>> if (-not (Get-PackageSource | Where-Object{ $_.Name -eq 'Nuget' }))
>> {
>> Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2
>> }
>> else
>> {
>> Write-Host "NuGet Already Exist! No Need to install."
>> };
>> };
PS C:\Users\egagn>
PS C:\Users\egagn> ## - Execute:
PS C:\Users\egagn> Verify-NugetRegistered
NuGet Already Exist! No Need to install.
PS C:\Users\egagn> Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2
Register-PackageSource : Package Source 'Nuget' exists.
At line:1 char:1
+ Register-PackageSource -Name Nuget -ProviderName NuGet -Location http ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceExists: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-PackageSource], Exception
+ FullyQualifiedErrorId : PackageSourceExists,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource

PS C:\Users\egagn> Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0 -Verbose
VERBOSE: Using the provider 'NuGet' for searching packages.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://dartmouth.myget.org/F/aig/auth/0bc6ec80-5fcf-42e3-9a3a-c862e1a70b65/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Searching repository 'https://dartmouth.myget.org/F/aig/auth/0bc6ec80-5fcf-42e3-9a3a-c862e1a70b65/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'Microsoft.Data.Sqlite.Core'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'Microsoft.Data.Sqlite.Core'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://dartmouth.myget.org/F/dba/auth/0bc6ec80-5fcf-42e3-9a3a-c862e1a70b65/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://dartmouth.myget.org/F/dba/auth/0bc6ec80-5fcf-42e3-9a3a-c862e1a70b65/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'Microsoft.Data.Sqlite.Core'.
Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Data.Sqlite.Core'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0 -Ve ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

PS C:\Users\egagn>

I also tried the following

PS C:\Users\egagn> Unregister-PackageSource dba
PS C:\Users\egagn> Unregister-PackageSource aig
PS C:\Users\egagn> Unregister-PackageSource PowerShellGet
Unregister-PackageSource : Unable to find package source 'PowerShellGet'. Use Get-PackageSource to see all available package sources.
At line:1 char:1
+ Unregister-PackageSource PowerShellGet
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power...erPackageSource:UnregisterPackageSource) [Unregister-PackageSource], Exception
+ FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UnregisterPackageSource

PS C:\Users\egagn> Unregister-PackageSource NuGet
PS C:\Users\egagn> Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
Nuget                            NuGet            False      https://www.nuget.org/api/v2


PS C:\Users\egagn> Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0 -Verbose
VERBOSE: Using the provider 'NuGet' for searching packages.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Searching repository 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Microsoft.Data.Sqlite.Core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'Microsoft.Data.Sqlite.Core'.
Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Data.Sqlite.Core'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0 -Ve ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Hum!!

OK! Drastic measure. If you want...

Uninstall PSCore6, and remove everything. I mean everything.

Before uninstalling Pwsh, make a list of all NuGet/PowerShellGalley module(s)/Package(s) then uninstall them all. Then, proceed to uninstall PSCore6. Please include all left over folders.

Then, do a clean installation of PSCore6, follow by registering Nuget, follow by the SQLLite package installation.

If you can, post the if it works.

:)

I was able to get it working. First I tried a fresh VM and it worked the first time. Had to run Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2)

Then I went back to my laptop. I was able to get it working by simply doing:

Unregister-PackageSource Nuget
Unregister-PackageSource Nuget.org
Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2

# Close PowerShell, re-open PowerShell

Install-Package Microsoft.Data.Sqlite.Core -RequiredVersion 2.0.0 -Scope CurrentUser -Verbose

After that, I found all the packages under C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages.

Now I'd like to import the package and use it. Here's my attempt:

PS C:\Users\egagn> $Packages = "C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages"                                                                                                  
PS C:\Users\egagn> [Reflection.Assembly]::LoadFile("$Packages\Microsoft.Data.Sqlite.Core.2.0.0\lib\netstandard2.0\Microsoft.Data.Sqlite.dll")                                                   

GAC    Version        Location                                                                                                                                                                  
---    -------        --------                                                                                                                                                                  
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\Microsoft.Data.Sqlite.Core.2.0.0\lib\netstandard2.0\Microsoft.Data.Sqlite.dll                               


PS C:\Users\egagn>                                                                                                                                                                              
PS C:\Users\egagn> # Not sure which one is needed, just import them all                                                                                                                         
PS C:\Users\egagn> $Targets = @("MonoAndroid","net35","net40","net45","netstandard1.0","netstandard1.1","portable-net40+sl5+netcore45+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10","portable-net
45+netcore45+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10","portable-net45+netcore45+wpa81+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10","uap10.0","win8","win81","wpa81","Xamarin.iOS10","Xamar
in.Mac20")                                                                                                                                                                                      
PS C:\Users\egagn> foreach($t in $Targets) {                                                                                                                                                    
>>     [Reflection.Assembly]::LoadFile("$Packages\SQLitePCLRaw.core.1.1.9\lib\$t\SQLitePCLRaw.core.dll")                                                                                        
>> }                                                                                                                                                                                            

GAC    Version        Location                                                                                                                                                                  
---    -------        --------                                                                                                                                                                  
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\MonoAndroid\SQLitePCLRaw.core.dll                                               
False  v2.0.50727     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\net35\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\net40\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\net45\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\netstandard1.0\SQLitePCLRaw.core.dll                                            
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\netstandard1.1\SQLitePCLRaw.core.dll                                            
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\portable-net40+sl5+netcore45+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQL... 
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\portable-net45+netcore45+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLit... 
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\S... 
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\uap10.0\SQLitePCLRaw.core.dll                                                   
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\win8\SQLitePCLRaw.core.dll                                                      
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\win81\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\wpa81\SQLitePCLRaw.core.dll                                                     
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\Xamarin.iOS10\SQLitePCLRaw.core.dll                                             
False  v4.0.30319     C:\Users\egagn\AppData\Local\PackageManagement\NuGet\Packages\SQLitePCLRaw.core.1.1.9\lib\Xamarin.Mac20\SQLitePCLRaw.core.dll                                             


PS C:\Users\egagn>                                                                                                                                                                              
PS C:\Users\egagn> $Connection = New-Object -TypeName Microsoft.Data.SQLite.SQLiteConnection                                                                                                    
PS C:\Users\egagn> $Connection.ConnectionString = "Data Source=C:\vault.db"                                                                                                                     
The following exception occurred while retrieving member "ConnectionString": "Could not load file or assembly 'SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab
535'. The system cannot find the file specified."                                                                                                                                               
At line:1 char:1                                                                                                                                                                                
+ $Connection.ConnectionString = "Data Source=C:\vault.db"                                                                                                                                      
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                      
+ CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException                                                                                                                     
+ FullyQualifiedErrorId : CatchFromBaseGetMember                                                                                                                                                

PS C:\Users\egagn>                                                                                                                                                                              

Oh well, I don't expect you to solve all my problems so I'm happy to close this ticket anytime you see fit. It does seem like I'm trying to do something that just isn't easy yet.

Please make sure to also send a note to the package owners.
They also should be able to help.

I'm glad I try to give you hand! Don't give up!
:)

Thanks for the encouragement, I will surely continue working on this and post a solution once I have it.

@MaximoTrinidad thanks for taking the time to help @elijahgagne

Since you were able to get the package to install, as @MaximoTrinidad noted you should follow up with the package owners on dotnetcore compatibility. (note that you can still reply to this thread while closed)

Was this page helpful?
0 / 5 - 0 ratings