Reputation: 1753
I've got an issue when packaging new packages with nuget in that when i specify the version by the command line it applies it to the package but not to dependencies. I.E.
NuGet.exe pack myproject.csproj -Version 3.0.4.3373
with a nuspec file
<?xml version="1.0"?>
<package>
<metadata>
<id>MyProject</id>
<version>$version$</version>
<authors>Me</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A description.</description>
<copyright>Copyright 2014</copyright>
<dependencies>
<dependency id="My.First.Dependency" version="[$version$]" />
<dependency id="My.Second.Dependency" version="[$version$]" />
</dependencies>
</metadata>
</package>
results in a package with the version 3.0.4.3373 but the dependencies are all written in as 1.0.0.0, which is not what I wanted. I want them to be the same version.
What have I got wrong here. I'm sure I've had this working before. I think I've used both 2.5 and 2.8 of nuget.exe for this.
Upvotes: 3
Views: 1425
Reputation: 1124
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
<?xml version="1.0"?>
<package>
<metadata>
<id>MyProject</id>
<version>$version$</version>
<authors>Me</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A description.</description>
<copyright>Copyright 2014</copyright>
<dependencies>
<dependency id="My.First.Dependency" version="[$PackageVersion$]" />
<dependency id="My.Second.Dependency" version="[$PackageVersion$]" />
</dependencies>
</metadata>
</package>
And then update your command
NuGet.exe pack myproject.csproj -Version 3.0.4.3373 -Properties "PackageVersion=3.0.4.3373"
It is not that clean, but it works.
Upvotes: 2