2016-03-04 111 views
0

項目間的依賴我無法弄清楚如何與一個解決方案項目和第三方組件的NuGet:在溶液

我有2個項目,AB溶液中引用創建一個包。 B參考文獻A。此外,B引用C這是一個dll位於Solution/libs

AB都應該是的NuGet包。

我有一個B.nuspec文件,該文件是這樣的:

<?xml version="1.0"?> 
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"> 
    <metadata> 
    <id>B</id> 
    <version>$version$</version> 
    <title>B</title> 
    <authors>me</authors> 
    <owners>me</owners> 
    <requireLicenseAcceptance>false</requireLicenseAcceptance> 
    <description>Description</description> 
    <copyright>Copyright © me 2016</copyright> 
    <references> 
     <reference file="C.dll" /> 
    </references> 
    </metadata> 
    <files> 
    <file src="..\libs\RMS\C.dll" target="lib"/> 
    </files> 
</package> 

我運行以下命令: nuget pack B.csproj -IncludeReferencedProject 正如本的NuGet文檔中說,將的NuGet從的csproj和nuspec結合信息。然而...

它給了我A.dllB.dll\lib\net45和nupkg在\libC.dll。也有一個nuspec文件

<?xml version="1.0"?> 
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"> 
    <metadata> 
    <id>B</id> 
    <version>1.0.31</version> 
    <title>B</title> 
    <authors>me</authors> 
    <owners>me</owners> 
    <requireLicenseAcceptance>false</requireLicenseAcceptance> 
    <description>Description</description> 
    <copyright>Copyright © me 2016</copyright> 
    <dependencies> 
     <dependency id="log4net" version="2.0.2" /> 
     <dependency id="JetBrains.Annotations" version="9.2.0" /> 
     <dependency id="morelinq" version="1.4.0" /> 
    </dependencies> 
    <references> 
     <reference file="C.dll" /> 
    </references> 
    </metadata> 
</package> 

當我安裝包到項目,沒有ABC參考。

我的設置有什麼問題?有沒有辦法創建一個包含從csproj和手動指定的引用(或者有一些隱藏的約定)的依賴包的方法?

+0

嘿,你找到一個解決方案?我在這裏面對的東西很相似 - http://stackoverflow.com/questions/36796591/nuget-package-referenced-assemblies-are-not-being-included-as-project-referenc – pharophy

+0

@pharophy是的,我剛剛添加C.dll到nuspec中的lib \ net40。重點是你需要將文件放在lib中的一個子文件夾中...... net45或net40 –

回答

1

有一個名爲NuProj的開源Visual Studio加載項,可以更好地處理這些場景。它由微軟員工Immo Landwerth開創。它定義了一個可以添加到解決方案的自定義NuProj項目類型,並且很好地處理引用。

你可以找到更多關於project website的信息。