Two different builds same source Visual Studio

Asked

Viewed 107 times

4

I have a Solution with several projects. I need to create two "profiles" of builds different for two situations. This is possible?

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

Can I put some configuration in my code and configure the build to generate these two versions of my choice?

1 answer

4


First you need to create a new configuration in VS. I took some images to help in Scott Hanselman’s page.

Go to the Configuration Manager:

Configuration Manager

Create a new configuration on the selector you probably already have Debug and Release. and choose one of them with copy source. You can create a new version of yours for debug and another to release:

Nova configuração

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

Build tab

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

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

Documentation of the conditional compilation directive.

Be careful with this, if you abuse you get lost.

Documentation of the settings manager.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.