31

Delphi 2009 uses build configurations. When you create a new project you have two default build configurations "Debug" and "Release".

Now I asked myself how to automate builds using MSBuild (which is supported by Delphi since version 2007).

You can start the "msbuild" command in the "RAD Studio Command Prompt" in some Delphi project directory and it will build the default build configuration (the last activated build configuration inside the Delphi IDE).

Now, I want to specify a certain (non-default) build configuration by a command line parameter.

The Delphi help asserts that the parameter is [/p:configuration=<configuration name>], which is wrong (Delphi 2009, Help Update 1)!

What is the right way?

ulrichb
  • 19,610
  • 8
  • 73
  • 87

3 Answers3

28

Now, if you want to change the build configuration you have to add the parameter
/p:config=<BUILD_CONFIG_NAME>

For example:

C:\Projects\TestDelphiApp001>msbuild /target:Build /p:config=Release

or

C:\Projects\TestDelphiApp001>msbuild /target:Build /p:config=Debug

Copied from original "question"; note community wiki.

Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273
  • You need to call `rsvars.bat` in your batch file first before this will work (at least in XE4, see [this answer](https://stackoverflow.com/a/17866719/2306907)). – yonojoy Jan 14 '22 at 11:15
10

I tried this with Delphi XE. It didn't work until I figured out I needed to set the environment variables referenced by the .dproj file:

SET BDS=C:\Program Files (x86)\Embarcadero\RAD Studio\8.0
SET BDSBIN=C:\Program Files (x86)\Embarcadero\RAD Studio\8.0\bin
SET BDSAPPDATABASEDIR=BDS
msbuild myproject.dproj /target:Build /p:config=Release
Jan Goyvaerts
  • 21,379
  • 7
  • 60
  • 72
  • 1
    Yes, Delphi XE creates a RAD Studio Command Prompt item in the start menu. That command prompt has the environment variables set. But I'm not actually typing things into the command prompt window. I'm running a batch file from my text editor, so the batch file needs to set up the environment. – Jan Goyvaerts Oct 05 '10 at 04:19
  • 12
    If your delphi (2009+ at least) is installed correctly, just do call rsvars.bat from your batch file and it will set the needed delphi build environment (that batch file is in the bin folder of delphi which is usually in the path in a regular installation) – ciuly Feb 23 '11 at 21:08
  • 2
    Note that the rsvars.bat file from Delphi 2007 sets some environment variables wrong for Windows 64 bit. (Just in case somebody tries the above with this combination.) – dummzeuch Aug 03 '14 at 14:03
3

I've had the same problem and found the solution:

  1. Write /p:config instead of /p:configuration
  2. Write "Release Build" or "Debug Build" (in double quotes) instead of Release or Debug

It did it for me.

Kromster
  • 7,181
  • 7
  • 63
  • 111
Slava
  • 39
  • 1