0

I can't figure out how to create a package with references to a solution project and a third party assembly

I have a solution with 2 projects, A and B. B references A. Also, B references C which is a dll located in Solution/libs

A and B are supposed to be nuget packages.

I have a B.nuspec file which is the following:

<?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>

I ran the following command: nuget pack B.csproj -IncludeReferencedProject As it is said in the nuget documentation, nuget will combine information from csproj and nuspec. However...

It gives me a nupkg with A.dll and B.dll in \lib\net45 and C.dll in \lib. Also there's a nuspec file

<?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>

And when I install the package into a project, none of A, B, C are referenced.

What's wrong with my setup? Is there a way to create a package with dependencies taken from csproj and references specified manually (or maybe there's some hidden convention?)

javros
  • 825
  • 10
  • 31
  • Hey, did you find a solution? I'm facing something pretty similar here - http://stackoverflow.com/questions/36796591/nuget-package-referenced-assemblies-are-not-being-included-as-project-referenc – pharophy Apr 22 '16 at 14:36
  • @pharophy yes, I just added C.dll to lib\net40 in nuspec. The point is that you need to place files in one subfolder in lib... either net45 or net40 – javros Jun 08 '16 at 12:04

1 Answers1

1

There's an open-source Visual Studio add-in called NuProj that does a better job with these scenarios. It was started by a Microsoft employee, Immo Landwerth. It defines a custom NuProj project type that you can add to your solution, and does a good job handling references.

You can find more information on the project website.

Thomas F. Abraham
  • 2,082
  • 1
  • 19
  • 24