views:

32

answers:

2

Hello,

I am creating a .NET assembly. I want to have 2 different versions of this assembly. The only difference between the 2 versions is a guid string which is embedded in a .cs file. So for version 1 of the assembly, the guid will be ECABAFD2-7F19-11D2-978E-0000F8757E2A and for version 2 ECABAFD2-7F19-11D2-978E-0000F8757E2B

How do I manage something like this in Visual Studio 2010 ? Is there some kind of automation tool that can change that string for me and compile both versions ?

How would you do it ? I am opened to suggestions

+1  A: 

If you want a slight change perhaps use the #if directive

#if FirstVersion
    _id = "ECABAFD2-7F19-11D2-978E-0000F8757E2A"
#else
    _id = "ECABAFD2-7F19-11D2-978E-0000F8757E2B"
#endif

Then you either use the command line to compile setting the directive or setup a new configuartion that you can switch.

As for having VS build both at the same time I would suggest a script or external build tool like Nant to do that.

aqwert
+1  A: 

In C#, conditional compilation is typically done using ConditionalAttribute. Place code using the relevant GUID values in your assembly that is Conditional on two different compilation symbols - say VARIANT1, VARIANT2.

Define build configurations for this project in Visual Studio that define VARIANT1 for the first build, VARIANT2 for the second build. This results in two output binaries - one with the first GUID and the other with the second.

Steve Townsend
perfect - thank you
GX