2016-11-30 112 views
2

我正在制作this NuGet包(source),其中pinvokes dll libxgboost.dll(它是从XGBoost构建的)。但是,它目前正在抛出异常,因为它找不到libxgboost.dll如何在NuGet包中包含pinvoked dll?

如何将libxgboost.dll包含到我的NuGet包中,以便我可以用它来制作它?

长途区号(带包安装)

using System; 
using XGBoost; 

namespace TestXGBoostPackage 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      XGBRegressor r = new XGBRegressor(); 
      float[][] X = new float[2][]; 
      X[0] = new float[2]; 
      X[0][0] = 0; 
      X[1] = new float[2]; 
      X[1][0] = 1; 
      float[] y = {0, 1}; 
      r.Fit(X, y); 
      Console.ReadKey(); 
     } 
    } 
} 

异常通过调用飞度()

An unhandled exception of type 'System.DllNotFoundException' occurred in XGBoost.dll 

Additional information: Unable to load DLL 'libxgboost.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 

DLL import语句)的飞度(PInvoked功能

时抛出
[DllImport("libxgboost.dll")] 
public static extern int XGDMatrixCreateFromMat(float[] data, ulong nrow, ulong ncol, 
               float missing, out IntPtr handle); 

用于包装

<?xml version="1.0"?> 
<package > 
    <metadata> 
    <id>PicNet.XGBoost</id> 
    <version>0.0.2.1</version> 
    <title>XGBoost.Net</title> 
    <authors>John Smith</authors> 
    <owners>John Smith</owners> 
    <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl> 
    <projectUrl>https://github.com/PicNet/XGBoost.Net</projectUrl> 
    <iconUrl>http://www.picnet.com.au/wp-content/uploads/2015/01/logo-dark.png</iconUrl> 
    <requireLicenseAcceptance>false</requireLicenseAcceptance> 
    <description>.Net wrapper for the XGBoost machine learning library.</description> 
    <releaseNotes>test dll dependency fix</releaseNotes> 
    <copyright>Copyright 2016</copyright> 
    <tags>machine learning xgboost boosted tree</tags> 
    </metadata> 
</package> 

在包的项目属性nuspec文件,构建输出路径是bin\Debug\和平台的目标是x64

回答

1

你可以收拾本地NuGet包的本地库,

https://docs.nuget.org/ndocs/create-packages/native-packages

然后你的管理NuGet包可以依靠这一点。

+0

感谢您的回答。这是否意味着我需要使用原始[XGBoost](https://github.com/dmlc/xgboost)C++代码创建本地NuGet包,然后在我的NuGet包中引用它?这是否意味着我必须采用不同的方式或使用不同于pinvoke的东西? – cycloidistic