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

删除回忆录丶 提交于 2019-12-18 04:50:42

问题


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...


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3063426/how-can-i-pass-a-parameter-through-msbuild-to-the-compiler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!