buildversioningmyget

Set Nuget Package Version from Project Info


My setup is rather simple: MyGet pulls my repo from GitHub on commit and builds. I then manually push the successfully built project to NuGet.

The version is manually set except for the build counter. Is there a way to pull the version from the AssemblyInfo, .csproj file or somewhere else?

I've read the docs and the only thing I can find is using GitVersion and a build file. I'm hoping there's a cleaner/simpler way, e.g. %project_version% :)


Solution

  • By definition, a build counter is managed by the build system and can only be reset at best.

    To use the version from AssemblyInfo.cs as the NuGet package version, you could create a .nuspec manifest next to your .csproj file (give it the same file name only differing by extension), and use the $version$ placeholder.

    I've got a blog post that explains this in further detail: https://www.xavierdecoster.com/post/2012/04/26/nuget-version-token-explained.html