Answered by:
Build MFC application through command line interface

Question
-
Hi there,
I use VS2010 to create a MFC DLL project. This project can generate different variation of DLL files based on different flag values defined through "#define"
I now would like to generate all variation of DLL files through command line interface. I can do so by typing the following command:
devenv MyDllProject.vcxproj /build Release
But what I can't figure out is how to pass the "#define" flags (ex. things like "_AFXDLL") as parameters into this command and produce different versions of DLL files. Below is what I would like to achieve:
devenv MyDllProject.vcxproj </D "FLAG1"> /build Release --> produce version 1 of DLL file
devenv MyDllProject.vcxproj </D "FLAG2"> /build Release --> produce version 2 of DLL file
And so on...
Is there a way of doing this kind of task?
Thanks in advance.
Tuesday, July 26, 2011 10:38 PM
Answers
-
Hello,
In addition of renjieluo's reply, the /D (Preprocessor Definitions) is a Compiler Options, you need set this in project's Property Pages. However, devenv *** is Devenv Command Line Switches, you need follow these switches in that document.
At last, you need to set /D in project's release or debug Property Pages, and then call devenv /build release or debug switch.
I hope my suggestions can help you to solve this problem.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Jesse Jiang Monday, August 8, 2011 11:37 AM
Wednesday, July 27, 2011 3:13 AM
All replies
-
Hi,
set CL=/DFLAG1
devenv ...
RenJie
Tuesday, July 26, 2011 10:58 PM -
Hello,
In addition of renjieluo's reply, the /D (Preprocessor Definitions) is a Compiler Options, you need set this in project's Property Pages. However, devenv *** is Devenv Command Line Switches, you need follow these switches in that document.
At last, you need to set /D in project's release or debug Property Pages, and then call devenv /build release or debug switch.
I hope my suggestions can help you to solve this problem.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Jesse Jiang Monday, August 8, 2011 11:37 AM
Wednesday, July 27, 2011 3:13 AM -
Hi Jesse,
Thank you for the suggestion. I understand that /D is set in project's property page. My problem is that I don't want to manually change the /D definition everytime when I build a specific version of DLL file. I am looking for something similar to this so that I can use it in command line interface.
I did some study in both devenv and MSBuild, but neither of them have a direct way of defining preprocessor flags as parameter. I will try RenJie's suggestion, although I don't know how CL can be linked to devenv.
If there's another work around to it, I am willing to hear about it.
Thanks,
Terence
Wednesday, July 27, 2011 6:26 AM -
Hi Terence,
As far as I know, you can change this value in vcxproj file. You can change it in Visual Studio.
Right Click your project->Unload Project, Right Click your project again->Edit xxx.vcxproj
/D is in the <ClCompile><PreprocessorDefinitions> node.
On the other hand, you can also change vcxproj file without Visual Studio, just use notepad to change.
If you want to know how to change this settings in MSbuild, you can open a new thread in MSBuild forum.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Proposed as answer by Jesse Jiang Monday, August 1, 2011 3:12 AM
Thursday, July 28, 2011 7:19 AM -
Hi Terence,
Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Tuesday, August 2, 2011 6:16 AM -
Hi Terence,
I marked my reply as answer, if your issue have not been solved please unmark it and update more information about this issue.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, August 8, 2011 11:37 AM