jqno
jqno

Reputation: 15520

Generating version number in MSBuild

We have a C# solution with a WiX installer and an MSBuild build script. We're in the process of migrating from SVN to Git.

As the fourth part of our version number, we want something that ascends with each build. Until now, we've used the SVN revision number for that. The MSBuild script defines a ProductVersion property, which included the SVN revision number as the final of the four numbers of the build version. However, we can't use that anymore, as we won't be using SVN anymore.

I've been trying to find a replacement for the SVN revision number, but I can't figure out what to use.

Again, I don't really care what the number is, as long as it increments with every build. Something based on a timestamp would be fine. Any ideas?

Upvotes: 6

Views: 11382

Answers (3)

Marcos Brigante
Marcos Brigante

Reputation: 1000

The MSbuild Community Tasks contains a task named Version, it provides some algorithms to generate version numbers. It is very easy to use and customizable.

IMHO, it is better to use a number that ties your entire SDLC, so you can trace your deployed product to the build results, and these to the VCS, and so forth. I would recommend using jenkins build number, as Christopher Painter did.

Upvotes: 7

Christopher Painter
Christopher Painter

Reputation: 55601

Why wouldn't you tie it to Jenkins? Seems like you'd want Jenkins to manager the properties that get passed into a build including version number. That's how I've done it with BuildForge, TFS et al.

Upvotes: 1

ChrisPatrick
ChrisPatrick

Reputation: 984

You can get the version number from an assembly by using !(bind.FileVersion.FileId) where FileId is the ID of a File element as defined in one of your wxs files.

Then just let .NET generate the Assembly numbers and WiX will use it as the ProductVersion.

Upvotes: 1

Related Questions