views:

26

answers:

2

I am building a C++ solution with Visual Studio 2005.

Sometimes I open the solution in Visual Studio and build it from within the development environment. Other times I build it from the command line using msbuild.exe. I'm wondering if there is a way that I can determine which of these two types of builds I'm using at compile time (for example, a macro or something like like that). I want to change the path of my output files based on this determination. So, if I'm building from within Visual Studio I would put my output files in FolderA but if I'm building from the command line I would put my output files in FolderB. Is this possible?

A: 

Perhaps you can pass in a command-line parameter when building from the command-line that would indicate you are building the solution from the command-line. Otherwise, you can assume you are building from within Visual Studio.

Bernard
This would be a good work around if there isn't a macro automatically provided by Visual Studio. I was curious if there was any there by default. If not, I will add my own as you suggest.
CyBri2000
A: 

I don't have the answer to your general question, but in order to change the output path, have you thought of adding project configurations ? You could copy project configurations and update the output path of the new ones.

Timores
I hadn't thought about creating a new project configuration for the command line build. It's not a bad idea, though it would introduce the need to maintain two configurations if we need to make changes to the configuration going forward. Thanks for the input!
CyBri2000
That's correct, although VC++ has the notion of putting some project settings in an external file and the ability for settings to be inherited from some kind of "solution default". May be worth investigating if you don't find a better solution.
Timores