Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass a parameter through MSBuild to the compiler?

Tags:

msbuild

delphi

I'm using the line below to have MSBuild build a Delphi 2010 groupproj:

   MSBuild C:\src\myprojgroup.groupproj  /target:Build /p:config=Release

I can't figure out how to modify the line above so that I can pass this argument

   -EC:\mypath

to the compiler (bcc32.exe).

I've spent a fair amount of time trying to find this on the web. /property:name=value seemed likely to be what I need, but hasn't thus far.

Is this even possible, or do I have to learn about MSBUILD configuration files now...

like image 843
RobertFrank Avatar asked Jun 17 '10 16:06

RobertFrank


2 Answers

Tom --

Probably the easiest way to do this would be to open the project in the IDE, set the settings in the IDE that you want, and then save.

Even better would be to set up a specific build configuration for these settings, and use that.

The IDE uses MSBuild itself, so any settings that you make in the IDE are saved in the *.DPROJ file (or GROUPPROJ, in your case), and so when you execute the command line, the exact same settings are used as were set in the IDE. If you use a specific build configuration for this specific set of options, you can simply call that configuration on the command line and you'll get what you want.

In other, shorter words: Let the IDE do the work for you.

like image 156
Nick Hodges Avatar answered Oct 04 '22 18:10

Nick Hodges


Change your build configuration within Delphi, or manually yourself in the .DPROJ file. If you change the Release config itself in either of those places, you'll be fine.

Alternately, look at the .dproj file and see what the setting you want is called (eg., "IncludePath" or "OutputDir"). You can then use msbuild's /property switch. For example:

msbuild /property:WarningLevel-2;OutputDir=bin\Debug myproj.dproj

You can see these command-line switches and examples using the following from a command window prompt:

msbuild /? | more

A quick check of a .dproj file from D2007 indicates you're probably looking for either the DCC_IncludePath or DCC_UnitSearchPath properties.

like image 25
Ken White Avatar answered Oct 04 '22 20:10

Ken White