2016-11-30 111 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