I have written a Visual Studio C# project and I have the need to create two executable, one for a “lite version” and one for a “full version” of the same project.
The “lite version” will be a stripped down version of the full one so I want to share everything (code, resources, etc.) and, if possible, use compiling directive to isolate code blocks.
Can you tell me a way to do this in a clean way?
You can create a new Conditional compilation symbol in your project (say
FULLVERSION). Create a new Solution configuration (say ReleaseFullversion) using the Configuration Manager, and in this configuration, define theFULLVERSIONconstant.You can then wrap code block with
or use the Conditional atrribute
to create a stripped down version your application.
Code within these
#if-blocks and theseConditionalattributes won’t be compiled into your assembly if theFULLVERSIONconstant is not set (theConditionalattributes just removes the call to that code block, actually).Then you would either build a lite version of your solution, or a Fullversion, which includes the full code.