Updating local nuget package on post-build event

Feb 23, 2011 at 3:26 PM

I have my local nuget library repository separately both for my personal and work releted class libraries.

I have created some of the nuget packages for the libraries which are no longer in development. I did olny for them because I do not know how to update them automatically as soon as my project is builded.

I have figured that all the work is being done by nuget command line with Visual Studio Command Prompt. So I can easily do the work I needed (of course I would know commands perfectly and I do not !)

basically I want the following works done on post-build event of my project

on project build,

  1. copying project dll into a specific folder (lib folder of the nuget package)
  2. updating nuspec file for new file version (my project is increasing the file version on every build)
  3. creating new nupkg file with new file version

Phil haccked show some of this feature but it is still on prototype and for project based as far as I have seen.

So my requirement is the above. anyone have done smthng like that before?

Feb 23, 2011 at 4:49 PM

Nothing does that today, but we’re looking into potential features that would support that. Typically what I’ll do today is setup a post build step as described in our docs (near the end):


I’ll manually update the nuspec version.

One of the tricky aspects is that a package isn’t always associated with a single assembly. So its version may not correspond to the assembly version. However, I think this is the most common case so we’ll look at making it work. After all, it’s quite possible you may have a project specifically to build a NuGet package and you would want the project’s version info in your package.

Feb 23, 2011 at 5:48 PM

Thanks for the answer Phil. So, I will have to do it as manual. That would be nice to have an auto incrementation feature per build.

Feb 23, 2011 at 5:54 PM

as you described on "Building a Package During the Visual Studio Build Process" section of http://nuget.codeplex.com/documentation?title=Creating%20a%20Package we can create the nuspec file.

my nuget.exe file is inside c:\library\@nuget\ and I want it to create the nuspec file inside the folder, whose name is the solution name, inside c:\library\@nuget\


solution name is mvclibrary1 and nuspec file needs to be on c:\library\@nuget\mvclibrary1\package.nuspec

Can I do that at least?

Feb 23, 2011 at 5:55 PM

Sure, just give it the full path to the nuspec file and the full output path.

Feb 24, 2011 at 9:39 AM

FYI, this is how I automatically copy assemblies, update the version and dependency version in nuspec and then create NuGet packages (two packages, one depending on the other) using MsBuild in one of my projects:


In my case I execute this MsBuild project on the continuous integration server as an artifact-dependent build, but it should work fine in a post-build event.

Feb 24, 2011 at 1:05 PM

@cdrnet thanks but the example is very complicated for my knowladge. can you direct me another way which will fit my knowledge on powershell and visual studio command prompt