How to include / exclude source files from the project depending on the assembly configuration?

I want to include the file in the project only in the configuration of the Debug assembly, and not in the Release assembly. How can I do this through the IDE?

I can already achieve this by manually editing the * .vcxproj file.

<ClCompile Include="..\..\..\..\dbg_helper.c" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"/> 

I am using Microsoft Visual Studio Express 2013 for Windows Desktop (version 12.0.21005.1 REL).

+7
visual-studio visual-studio-2013
source share
2 answers

If you want to exclude it from the assembly, and not from the entire project tree, you can do this from the user interface.

Just edit the file properties.

file properties file properties

Now you can change the desired configuration for which you want to edit its properties. enter image description here enter image description here

Exclude file for all configurations and platforms. enter image description here And then enable it only for the configuration you want to create. enter image description here

+2
source share

Unloading the project and editing the file manually is technically carried out through the IDE, so I assume that you are looking for a way to do this through the Project Properties, it is not possible .. p>

In C #, you can decorate your class with ConditionalAttribute as follows:

 [Conditional("DEBUG")] // or another constant you use in your configurations public class MyClass { ... } 

And similar for C ++:

 #if DEBUG // or another constant you use in your configurations ... #endif 

However, I would not recommend using it too much, as you may run into problems.

0
source share

All Articles