Building a Project Using an MSBuild Command

From RAD Studio
Jump to: navigation, search

Go Up to How To Compile and Build Applications


The IDE uses Microsoft's MSBuild engine to build a project. You can build projects without knowing anything about MSBuild; the IDE handles all the details for you. However, you can also directly build the project using MSBuild command-line syntax as described here. When you build a project, the results of the build appear in the Output pane of the Messages window. If you have entered build events, the build output pane displays the commands you specified and their results.

MSBuild command-line syntax has the form:

MSBuild <projectname> [/t:<target name>][/p:config=<configuration_name>][target:Deploy][/p:platform=<platform_node_name>]

Building a Project Using the Command Line

  1. From the Start menu, select Embarcadero RAD Studio | RAD Studio Command Prompt. The command prompt window automatically sets the environment for using RAD Studio tools such as MSBuild.exe.
    Note: In later versions of Windows OS, the shortcut will be available in your application list menu.
  2. Navigate to the directory that contains your project, such as C:\Users\<user>\Documents\Embarcadero\Studio\Projects\MyProject.
  3. Type msbuild but do not press Return yet.
  4. Enter your project name, such as TelePoll.dproj (a Delphi project) or UserInfo.cbproj (a C++ project).If the project is not in the current directory, you must include the full path name to the project directory.
  5. To specify a target, enter the /t: tag followed by one of the targets specified in your project file. The three standard target names are clean, make, and build:
    • Clean means to clean the project, removing generated files such as object code. Clean corresponds to the Project Manager context menu item Clean.
    • Make means to compile the project. Make corresponds to the context menu item Compile.
    • Build means to build the project. Build corresponds to the context menu item Build.The three targets are similar to the Clean, Compile, and Build commands on the context menu in the Project Manager. The default target is build.
  6. To specify a configuration, enter the configuration name after /p:config =.If you do not specify a configuration, MSBuild uses the current active configuration.To specify a configuration, use the name of one of the existing build configurations in your project. This can be either a default configuration, such as Debug, or a configuration you have added to the project. If the configuration name has a space in it, enter the name bounded by double quotes, such as:/p:config ="My config"
  7. To prepare your application for deployment, add the /target:Deploy option.
  8. Enter any other options and press Return to begin the build.
Tip: To display online help for MSBuild (including a full example command line), open the RAD Studio Command Prompt (see Step 1) and enter MSBuild /help.

For more information about MSBuild, see Microsoft documentation at http://msdn.microsoft.com/library/default.aspx.

Building an Android or iOS Application Using the Command Line

Creating the apk or ipa package file requires the *.deployproj file. This file is only generated from the IDE. You need to deploy your application form the IDE each time you make changes in the Deployment Manager to have the *.deployproj file updated. Click Deploy DMgrDeploy.png to create again the file.

From the IDE:

  1. Select the options for your project on the Projects Window: Build Configuration and target platform.
  2. Compile the project.
  3. Go to Project > Deployment and click Deploy DMgrDeploy.png.
    Note: This generates a *.deployproj file that works with MSBuild.
  4. Save the project.

From MSBuild:

Examples

To clarify, consider the following sample MSBuild commands:

  • To create an .apk installer to deploy your C++Builder project to the Android target platform, use a command similar to the following syntax:

msbuild MyApps_CBuilder.cbproj /t:Build /p:Config=Debug /target:Deploy /p:platform=Android

  • To deploy your Delphi project to the iOS32 target platform, use a command similar to the following syntax:

msbuild MyProj_Delphi.dproj /t:Build /p:Config=Debug /target:Deploy /p:platform=iOSDevice32

See Also