Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VC++ 2010 - Adding configuration to a single project in a solution fails to build

I have the following situation:

I have a solution with ~20 C++ projects. Most are static libs, a few are DLL's and some executables. This solution has two configurations - Debug and Release, and two platforms - Win32 and x64. All has been working great for a long time.

Now I wanted to have two different behaviors for a specific static library (lib_core) - X and Y. So I added a few #ifdef's in this library code with a macro USE_X. I created a new solution configuration "Release_X" based on "Release", and renamed "Release" to "Release_Y".

I then did the same for the projects configuration of lib_core, assigned the relevant project configurations to the same solution configurations, and added the macro USE_X to Release_X project configuration.

All other projects (some of them are not even mine, so I can't change them anyway) remain with Release and Debug configurations.

Now when I tried building the project (and clean/rebuild, just in case) - lib_core fails to build with:

2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(283,5): 
error MSB8013: This project doesn't contain the Configuration and Platform combination of Release|Win32.

What is the problem here?

How can I make this work?

like image 462
Asaf Avatar asked Jan 29 '14 09:01

Asaf


People also ask

How do you add a configuration to a project?

Create a project configurationSelect a project in the Project column. In the Configuration drop-down list for that project, choose New. The New Project Configuration dialog box opens. In the Name box, enter a name for the new configuration.

How do I change the build configuration in Visual Studio?

Right-click on the project node and select Options. You can also double-click on the project node to bring up the Project Options dialog. Select Add to create a new configuration. You can also copy any of the existing configurations.

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.

What is build configuration in Visual Studio?

Applies to: Visual Studio Visual Studio for Mac Visual Studio Code. You need build configurations when you need to build your projects with different settings. For example, Debug and Release are build configurations, and different compiler options are used accordingly when building them.


1 Answers

Apparently all I needed to do was to unload the project and reload it, and everything started working fine. I guess closing and reopening VS would have worked the same way.

When I changed the MSBuild output to diagnostics mode, I saw that the configuration of the project was defined as "Release". After unloading and reloading it worked out.

like image 192
Asaf Avatar answered Oct 21 '22 00:10

Asaf