Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to include a file in the project only under the 'Debug' build configuration and not in the 'Release' build. How can I do that via the IDE?

I am already able to achieve the above 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).

like image 482
work.bin Avatar asked Jun 24 '16 11:06

work.bin


People also ask

How do you exclude a project from a build?

On the menu bar, choose Build > Configuration Manager. In the Project contexts table, locate the project you want to exclude from the build. In the Build column for the project, clear the check box. Choose the Close button, and then rebuild the solution.

How do I get excluded files in Visual Studio?

We can right click on the file, choose properties, go to General and click on Excluded From Build, then choose Yes or No to exclude or re-include.

How do you add sources to a project?

Right click on the User Source Files folder and choose one of the Files to Source File Folder menus to open a file dialog. The Copy menu copies the source file to the project folder and adds it to the project list. The Add function adds the file and its path without moving it to the project folder.


1 Answers

If you only want to exclude it from the build and not from the entire project tree, you can do it from UI.

Just edit the file properties.

file properties file properties

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

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

like image 73
Anateus Avatar answered Oct 20 '22 19:10

Anateus