My 200th Post

As I blogged about earlier, the other day I sat down and cranked out 3 articles for my Builder.com column. They all had to deal with versioning, and they were all based on conversations I had on my blog. I sent Paul Alexander from Xheo.com (someone get this guy a blog already!) my article on SxS versioning and the Framework, which stemmed from a heated debate with Frans Bourma, and he replied with this single comment.

You really should mention the ability to use conditional compilation to maintain a single code base targeted toward multiple versions.

 I use VS.NET and a configuration property to compile the same codebase against both 1.0 and 1.1.

Woah. I was dumbfounded. Is that possible? How would one go about doing this?... so many questions floated thru my head.

Now, I love Paul. He's a great guy. He's been working with me long enough to know that I'm gonna ask for sample code. That's just the way I work... I can't learn without seeing it in action. Did he include sample code? NOOOOO.... so I had to ask. ;)

This is what he sent back to me:

#if NET11
     ..do something specific to .NET 1.1
#else
    ..do something specific to .NET 1.0
#endif

#insert heavenly choir here. The heavens part, angels float down on clouds, and the voice of God says quietly "and it was Good."

I sat for a few moments in quiet awe. This is the magical answer that I was looking for. Single codebase, dual compilation. Simplicity at it's finest.

Then it dawned on me. "Nope. That's too simple. There HAS to be something else going on. *Que Trillian!*

Paul, what did you mean by "a configuration property"?

*wait a few seconds*

Paul Alexander Says:
     -First, you have to create 2 separate solution files and 2 separate project files. Make one for 1.0 and one for 1.1.
     -Next, right click on the project, and go to Configuration Properties | Build | Conditional Compilation Constants, and create a constant (NET11=True) for your .NET 1.1 projects only)
When you compile in your 1.1 project, it will see that the constant you set = true, and will compile that code instead.

*elation fades*

You know, I would do a backflip if VS.NET had those constants built in. One would think.. This works too tho. Since I'm using the Workspaces as my SCC provider, I think it will still put 2 copies in the source control, meaning that I'll still have to update code in 2 places, but a file copy is better then hunting thru code for line replacements.

So, Frans, for my 200th entry *applause*, I've given you a simple solution from the simple solution guy (and Paul). Hope this finally puts your mind to rest on the subject.

If you'll excuse me, I have 3 articles I now have to modify. *mock frustration* Hey Paul, THANKS ALOT ;).

1 Comment

  • This still doesn't change the referenced system.dll to version 1.0.3300 when compiling under vs.net 2003, it allows you to keep 2 separate codebases in one codebase. The problem I referred to was that you had 1 codebase, a .net 1.0 compatible one, and it is compiled using a tool which only understands .net 1.1.

Comments have been disabled for this content.