2014-11-03 36 views
1

我有一個NuGet包(MyPkg),它包含依賴於另一個包(AnotherPkg)中的構建任務的構建目標。 AnotherPkg具有該構建任務DLL的工具目錄。在NuGet行爲之後,DLL被安裝到\ packages \ AnotherPkg.0.1.1 \ tools從另一個包引用NuGet包的工具

我想知道是否有正確的方法來引用AnotherPkg的工具路徑並使其版本不可知。例如,我希望軟件包用戶能夠將AnotherPkg升級到0.1.2,而不必在我的軟件包中更改任何內容。

我有一些代碼可以試着找到AnotherPkg的目錄......但它看起來有點片狀,如果AnotherPkg尚未安裝,項目可能無法加載。

<ItemGroup> 
    <AnotherPkgDll Include="$(SolutionDir)\packages\AnotherPkg.*\tools\AnotherPkg.Tasks.dll" /> 
</ItemGroup> 
<UsingTask AssemblyFile="@(AnotherPkgDll)" TaskName="Whatever" /> 

其他提示?我希望我錯過某種NuGet函數來獲取這些信息。

+1

不要依賴$(SolutionDir),如果沒有解決方案文件,您將無法在命令行上構建。請使用$(MSBuildThisFileDirectory).. \ AnotherPkg。*,並考慮使用用戶可定製屬性來修復AnotherPkg的版本號,如AnotherPkg。$(AnotherPkgVersion)\ tools \ AnotherPkg.tasks – 2014-11-05 06:08:53

回答

-1

我試圖在我的軟件包中使用的軟件包位於Github上。所以我修改了它並提交了一個拉取請求。 :)