如何在PowerShell 6模块中引用nuget包

时间:2018-12-04 14:21:54

标签: powershell powershell-v6.0

我在PowerShell中使用nuget安装了一个软件包:

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

在此位置安装了DLL的

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

我在模块清单(psd1)中引用DLL:

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

当我加载使用DLL的模块时,出现错误:

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.

我可能可以直接加载程序集:

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

我想,另一个选择是将Packages文件夹添加到$PATH

在PowerShell中是否有惯用的方法来解决此问题?

0 个答案:

没有答案