How do reference a nuget package in a PowerShell 6 module

471 Views Asked by At

I installed a package using nuget in PowerShell:

PS > install-package gudusoft.gsqlparser -source https://www.nuget.org/api/v2

Which installed DLL in this location:

/usr/local/share/PackageManagement/NuGet/Packages/gudusoft.gsqlparser.3.2.6.5/lib/netcoreapp2.0/gudusoft.gsqlparser.dll

I referencing the DLL in the module's manifest (psd1):

RequiredAssemblies = @('gudusoft.gsqlparser.dll')

When I load the module that uses the DLL, I get an error:

PS > import-module pssqlparser                    
import-module : Could not load file or assembly 'gudusoft.gsqlparser, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

I can probably load the assembly directly:

Add-Type -Path '/usr/local/share/PackageManagement/NuGet/Packages/gudusoft.gsqlparser.3.2.6.5/lib/netcoreapp2.0/gudusoft.gsqlparser.dll'

Another option, I suppose, it to add the Packages folder to the $PATH.

Is there an idiomatic way to address this issue in PowerShell?

0

There are 0 best solutions below