Help with command line option

delphi package - automated exception handling
dipold
Posts: 5
Joined: Wed Nov 11, 2015 6:54 pm

Help with command line option

Post by dipold »

I'm trying to compile a project from the command line without success:

I build the project with the follow command line:
msbuild /t:Build /p:config=Release;DCC_MapFile=3;DCC_Define="MADEXCEPT;DEBUG" C:\MY_PATH\MY_PROJECT.DPROJ

In C:\MY_PATH\BIN\ there are 3 files:
MY_PROJECT.EXE
MY_PROJECT.MAP
MY_PROJECT.MES

Then I run the command manually:
"c:\Program Files (x86)\madCollection\madExcept\Tools\madExceptPatch.exe" "C:\MY_PATH\BIN\MY_PROJECT.EXE"

And get message:
Binary patched.
map file appended

The MY_PROJECT.EXE file increases size byte, but the MadExcept report doesn't work.
But if I build the same project inside IDE, works like a charm.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Help with command line option

Post by madshi »

I'm not familiar with the msbuild parameters. But I can tell you that you need to enable the *compiler* debug options, while you can keep the *linker* debug options off (except for the map file which needs to be set to "detailed"). Hope that helps?
dipold
Posts: 5
Joined: Wed Nov 11, 2015 6:54 pm

Re: Help with command line option

Post by dipold »

Thank you for response!

Ok, but I'm not able to find *compiler debug options* in the *Project Options* in the IDE. Could you be more specific?

For example, Map File:
Project > Options > Delphi Compiler > Linking > Map File (http://docwiki.embarcadero.com/RADStudio/XE6/en/Linking)

Compiler Debug Options:
Project > Options > ?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Help with command line option

Post by madshi »

The place to find it differs with the Delphi version you're using, and you didn't tell me which version that is... :wink:
dipold
Posts: 5
Joined: Wed Nov 11, 2015 6:54 pm

Re: Help with command line option

Post by dipold »

It's Delphi XE6.
Sorry, I just telling the version from the link only, although I work with Delphi since version 3.0 :wink:
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Help with command line option

Post by madshi »

See project options -> delphi compiler -> compiling. The first section "debugging" must be set correctly. I'm not sure from the top of my head which options madExcept needs there. But you can try yourself: In a project using madExcept, disable all those options. Then compile. Then check again. madExcept should automatically have reactivated the options it needs.
ciuly
Posts: 65
Joined: Mon Apr 30, 2007 1:16 pm
Location: Romania

Re: Help with command line option

Post by ciuly »

you are building Release configuration with a DEFINE of "DEBUG". that doesn't look very smart.
it's also a good idea to specify your platform
/p:platform=Win32
even if you only have that 1 platform. In the future you may add other platforms and you'll start wondering why your "desired" one isn't building from command line.
finally, it is always a good idea to keep existing defined variables, so you would want something like this
msbuild /t:Build /p:platform=Win32 /p:config=Release;DCC_MapFile=3;DCC_Define="$(DCC_Define);MADEXCEPT;DEBUG" C:\MY_PATH\MY_PROJECT.DPROJ
unless your build logic specifically needs to override your currently defined ones.
But personally, I prefer creating my desired configurations, tree-like and use option set files for the various aspects (so I will have specific configs under release and under debug). All that cleans up my commandline compilation to calling msbuild with platform and configuration parameters only. It also makes the command line build very similar to the IDE build, so it something is working on my end, built from IDE and not for the customer built from command line, I can rest assured it's not from the build process/parameters (once the CLI build is proven to do what it's supposed to do)

long story short, beside the defines, make sure any other command line options you pass on to msbuild doesn't override stuff, but adds them. Or if it needs to overwrite, then also include the IDE mandatory things (look in the IDE to see what is checked)
dipold
Posts: 5
Joined: Wed Nov 11, 2015 6:54 pm

Re: Help with command line option

Post by dipold »

@ciuly
I try expose a minimal e verifiable example. So this is not my complete code.
In fact, I ended up making a typo in building config property in my post above and I apologize. The correct is /p:config=Debug

About DCC_DEFINE, I'm building this programmatically, because $(DCC_Define) apparently does not work in command line:
http://stackoverflow.com/questions/8507 ... mmand-line

As I'm using Debug Build Configuration from .dproj, there are nothing being overridden from IDE default settings, so I'm struggling to understand what could be wrong.

@madshi
I tried to change one-by-one all options in Delphi Compiler > Compiling and unfortunately I was not successful.
MadExcept reactive just the *Debug information* and *Local Symbols*, but they are already activated in my .dproj in Debug Build Configuration.

I'll abandon the idea of automating the compilation with MadExcept for a moment and do it manually because now I have other priorities.

Maybe someone has a future insight about this.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Help with command line option

Post by madshi »

There are lots of people who do automate compiling successfully, so it must be possible somehow. I'm doing it myself, however, I'm using dcc32 instead of msbuild, so I'm not sure where the problem comes from.
ciuly
Posts: 65
Joined: Mon Apr 30, 2007 1:16 pm
Location: Romania

Re: Help with command line option

Post by ciuly »

my note about overriding the IDE stuff was targeting your command line. let me put it this way: whatever you place on the command line, overrides your IDE-configured settings. So that's why it is best, in this case, to place your exact command line calling msbuild and not an approximation.

I vaguely remember having a similar issue years ago. Searching through my old scripts, I didn't find a workaround that would allow passing DCC_Define as msbuild param I am using optset files since around that time so maybe I followed my own suggestion: upgrade yourself :)

however, this boils down to: why do you really need that passed on the command line?
sure, eons ago you were not able to configure a project in such a way that debug got one set of stuff, release got another set of stuff, and the project itself would be unaltered. The IDE would always modify some project files and then dcc32 would pick those changes up, so in order to do that without the IDE you'd pass things on command line to dcc32.

But those ages are long gone. Nowadays you can do whatever configurations you want and just call those from command line. You can even define build groups since xe3 I think.

So why aren't you using the new features of the IDE? It would make your life (cli building) a lot easier.
dipold
Posts: 5
Joined: Wed Nov 11, 2015 6:54 pm

Re: Help with command line option

Post by dipold »

@madshi
I believe you. I'm making mistake somewhere and maybe I'll have better luck in next attempt...

@ciuly
There is an old service tool at the company I work, which synchronizes real-time changes in different versions of existing projects in a VCS server, and creates a build of the executables affected by the changes, so compile/compact/audit logs/notify users/etc...
Anyway, it's hard to explain, but this entire process occurs without human intervention. I know there are more current ways or third-party tools that make service much better ways, but this decision is not in my hands...
ciuly
Posts: 65
Joined: Mon Apr 30, 2007 1:16 pm
Location: Romania

Re: Help with command line option

Post by ciuly »

since it uses msbuild, it cannot be "that old" ;)
and since you are considering fiddling with the build command itself, you do have some control over the build (at least)
better tell us what you are not allowed to change, it can't be that many.
like, can you change the dproj files? I can't imagine that being a restriction, and if it's not, I don't see why you can't implement what I said, as it makes no difference what :old system" is in place or not
siUs
Posts: 6
Joined: Tue May 03, 2016 1:27 pm

Re: Help with command line option

Post by siUs »

Hello, i have the same probleme. did someone found a solution?

I build a new delphi seattle vcl application with one button (for creating an exception).

And when I start the batch file I only get the message: map file appended but not binary patched.

Code: Select all

MSBuild S:\MadTest\Test.dproj /target:Build /p:config=Debug

"C:\Program Files (x86)\madCollection\madExcept\Tools\madExceptPatch.exe" "S:\MadTest\Test.exe" "S:\MadTest\Win32\Debug\Test.mes" "S:\MadTest\Test.map"
In the Test.mes file, HandleExceptions=1 is set and all debug options.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Help with command line option

Post by madshi »

Then probably the map file is incomplete. Do you have all compiler debug options enabled, and the map file set to "detailed"?
siUs
Posts: 6
Joined: Tue May 03, 2016 1:27 pm

Re: Help with command line option

Post by siUs »

yes i think so.
DelphiDebug.PNG
DelphiDebug.PNG (30.74 KiB) Viewed 14708 times
DelphiDebugLinker.PNG
DelphiDebugLinker.PNG (32.16 KiB) Viewed 14708 times
Post Reply