3
votes

So, previously we called nuget pack with the nuspec file (nuget pack myproj.nuspec). The nuspec looked something like this:

<package>
  <metadata>
    <version>$version$</version>
    [more properties]
    <dependencies>
      <dependency id="MySubProj" version="$version$" />
      [more explicit dependencies]
    </dependencies>
  </metadata>  
</package>

I switched the call to (nuget pack myproj.csproj) so our always-outdated explicit dependencies would be auto-generated.

Everything works great, except now the finished nuspec is something like

<package>
  <metadata>
    <version>1.2.3.4</version>
    [more properties]
    <dependencies>
      <dependency id="MySubProj" version="0.0.0.0" />
      [more explicit dependencies]
    </dependencies>
  </metadata>  
</package>

While the correct version of MySubProj would also be 1.2.3.4.

More infos:

  • MySubProj is a project in the same solution
  • It is bundled into a separate nuget package
  • The version of the MySubProj nuget package as well as the version of the bundled dll are correct.

I don't get what I am doing wrong really and why it would work when using the nuspec directly vs the csproj :/

1

1 Answers

2
votes

Seems like a very old bug while using a csproj combined with nuspec (which is still there with NuGet 3.5) ...

One way of making this working is by adding an extra property

<package>
  <metadata>
    <version>$version$</version>
    [more properties]
    <dependencies>
      <dependency id="MySubProj" version="$PackageVersion$" />
      [more explicit dependencies]
    </dependencies>
  </metadata>  
</package>

And then update your command

NuGet.exe pack myproject.csproj -Version 1.2.3.4 -Properties "PackageVersion=1.2.3.4"

It is not that clean, but it works.