Two different builds same source Visual Studio

4

I have a solution with several projects. I need to create two different builds profiles for two situations. Is this possible?

In build A I'll show the X, Y, and Z menus. In build B I will only show the Y and Z menus.

Is there any way I can put some configuration in my code and configure build to generate these two versions of my choice?

    
asked by anonymous 08.01.2015 / 13:08

1 answer

4

First you need to create a new configuration in VS. I've taken some pictures to help the Scott Hanselman page .

Go to Configuration Manager :

CreateanewsettingintheselectorwhereyouprobablyalreadyhaveDebugandRelease.andchooseonewithcopysource.Youcancreateanewversionofandrelease:

Then you will go to the property page for your project. In the tab Build you will create a conditional compilation symbol . It would be nice to use a name like the name you used in the newly created configuration, just to standardize. You will obviously create this symbol by choosing the new setting you created.

Then in your code you will use #if SIMBOLO_CRIADO to choose whether that code snippet should be compiled in that version or not.

#if MENU1
    ChamaMenu1();
#elif MENU2
    ChamaMenu2();
#endif

Conditional Compilation Policy Documentation .

Watch out for this, if you abuse it you start to get lost.

Configuration Manager Documentation .

    
08.01.2015 / 13:47