specify dependency version with "nuget pack"

Feb 21, 2012 at 1:10 PM


Is it possible to specify a dependency version on the command line?


I've got TFS to build my nuget packages and i want them to be in sync such that installing a package will always get the exact same version of the support libraries 

Feb 22, 2012 at 5:59 PM
Not exactly. You can use a build tool and add a step to XML poke the version in. Here is an example lifted from roundhouse that can be used as an example:

<xmlpoke file="${spec.file}"
"Be passionate in all you do"


Feb 23, 2012 at 6:59 AM

hmm, i wonder if msbuild got a step to do that ...

it appears that MSBuild Extensions has something i need beacuse i've got a number of nuspec files, and a different number of dependencies per nuspec, replacing a token in the nuspec file seems, right now, to be a better choice

but i probably should look into doing it in the TFS workflow and use some sort of templating structure instead ....

I'll get back with my final solution...

Feb 29, 2012 at 12:19 AM
Edited Feb 29, 2012 at 12:24 AM

I'm using the -Properties option of nuget pack to do something similar to what I think you're asking.

In my .nuspec file, I specify my dependency as

<dependency id="My.Dependency.Package" version="$mycommonversion$" />

Then from the command line, I invoke the pack command like:

nuget pack -p "MyCommonVersion=" My.Dependent.Package.nuspec

This seems to be working fine for all the substitutions I want to make in my .nuspec file, and has the advantage (or disadvantage depending on your viewpoint) that the .nuspec file cannot be packed unless all the expected replacement tokens have been given values from the command line

Mar 1, 2012 at 8:26 AM

Grrrrrreeeeaaaaaatt as tigr would say :) just what i wanted :)

Mar 1, 2012 at 8:48 AM
Edited Mar 1, 2012 at 8:58 AM

If i'm using the -version arg, could i just use $version$ in the dependency?


After a trial run it actually just works with $version$ as I am specifing the version in the command line as well

nuget pack -version x.y.z.v blablabla ..


then $version$ is just as valid :)