Versioning and Continuous Integration with project settings files

Posted by Michael Stephenson on Geeks with Blogs See other posts from Geeks with Blogs or by Michael Stephenson
Published on Sat, 22 May 2010 08:49:56 GMT Indexed on 2010/05/22 9:02 UTC
Read the original article Hit count: 368

Filed under:

I came across something which was a bit of a pain in the bottom the other week.

Our scenario was that we had implemented a helper style assembly which had some custom configuration implemented through the project settings. I'm sure most of you are familiar with this where you end up with a settings file which is viewable through the C# project file and you can configure some basic settings.

The settings are embedded in the assembly during compilation to be part of a DefaultValue attribute. You have the ability to override the settings by adding information to your app.config and if the app.config doesn’t override the settings then the embedded default is used.

All normal C# stuff so far…

Where our pain started was when we implement Continuous Integration and we wanted to version all of this from our build. What I was finding was that the assembly was versioned fine but the embedded default value was maintaining the non CI build version number.

I ended up getting this to work by using a build task to change the version numbers in the following files:

  • App.config
  • Settings.settings
  • Settings.designer.cs

I think I probably could have got away with just the settings.designer.cs, but wanted to keep them all consistent incase we had to look at the code on the build server for some reason.

I think the reason this was painful was because the settings.designer.cs is only updated through Visual Studio and it writes out the code to this file including the DefaultValue attribute when the project is saved rather than as part of the compilation process. The compile just compiles the already existing C# file.

As I said we got it working, and it was a bit of a pain. If anyone has a better solution for this I'd love to hear it

© Geeks with Blogs or respective owner