11

Starting to make a lot of use out of the build events system in XE, but one thing I noticed is that I'm unable to set up default build events in the default project settings. Is there any sort of workaround/hack/whatever that would make this possible? I'm looking at CodeGear.Group.Targets and CodeGear.Delphi.Targets in the bin directory, if this is even doable, would that be where I should be looking?

Thanks

RRUZ
  • 134,889
  • 20
  • 356
  • 483
Jen Smith
  • 261
  • 1
  • 9
  • 1
    +1. I too would like this very much. Every time I build somthing I want a .bat to execute. Now I have to add this script to every new project, which is annoying. – Andreas Rejbrand Dec 15 '10 at 14:15
  • 1
    Welcome to StackOverflow, Jen. It's good to see that you were able to ask a good question and give a good answer your first time. :) – Mason Wheeler Dec 16 '10 at 01:24
  • Thanks :) Was toying with it for a couple days off and on, and of course I figure it out a half hour after asking about it lol.. hopefully Embarcadero implements something like this into the IDE with their next version instead of having to rely on a kludge. – Jen Smith Dec 16 '10 at 03:15

2 Answers2

15

Ah ha. Answered my own question. (Is there a delete button somewhere? Lol)

I did some experimenting, added some easy to find pre and post build events (namely launching the registry editor and notepad..)

In Delphi's bin directory there's a file called CodeGear.Delphi.Targets. Inside that, after the import sections, I added:

<PropertyGroup>
     <PreBuildEvent><![CDATA[regedit.exe]]></PreBuildEvent>
     <PostBuildEvent><![CDATA[notepad.exe $(MSBuildProjectFile)]]></PostBuildEvent>
</PropertyGroup>

Restarted the IDE, and a new empty project executed those programs on pre and post build. Note that they don't show up on the project configuration screen though, but you can override them, negating whatever was put in the CodeGear.Delphi.Targets file. Cheap, but it seems to do the trick, and you can still override it if needed on a specific project. (Just make sure to back the original file up of course.)

Jen Smith
  • 261
  • 1
  • 9
  • 3
    Answering your own question's perfectly fine on SO, if you figure it out before anyone else does! – David Dec 15 '10 at 22:54
  • 1
    So far I have only asked one question on SO, then answered it myself! But leave these questions in SO, so others can find your answer. – Gerry Coll Dec 16 '10 at 06:22
1

@Jen Smith: Very clever. And in case someone is interested I've now used your idea to get madExcept to patch the binary exe as part of a command line build without having to customise a specific project..:

Put this after the 'Import' section of CodeGear.Delphi.Targets..

  <PropertyGroup>
    <PostBuildEvent><![CDATA["$(programFilesx86)\madCollection\madExcept\Tools\madExceptPatch.exe" "$(DCC_ExeOutput)$(MSBuildProjectName).exe" "$(MSBuildProjectDirectory)\$(MSBuildProjectName).mes"]]></PostBuildEvent>
  </PropertyGroup>
Brian Frost
  • 13,334
  • 11
  • 80
  • 154