简体   繁体   English

Delphi MSBuild 从命令行构建配置

[英]Delphi MSBuild Build Configurations From Command Line

Delphi 2009 uses build configurations . Delphi 2009 使用构建配置 When you create a new project you have two default build configurations "Debug" and "Release".当你创建一个新项目时,你有两个默认的构建配置“Debug”和“Release”。

Now I asked myself how to automate builds using MSBuild (which is supported by Delphi since version 2007).现在我问自己如何使用 MSBuild(自 2007 版起受 Delphi 支持)自动构建。

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).您可以在某些 Delphi 项目目录的“RAD Studio 命令提示符”中启动“msbuild”命令,它将构建默认构建配置(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)! Delphi 帮助断言参数是 [/p:configuration= <configuration name >],这是错误的(Delphi 2009,Help Update 1)!

What is the right way?什么是正确的方法?

Now, if you want to change the build configuration you have to add the parameter现在,如果你想改变构建配置,你必须添加参数
/p:config= <BUILD_CONFIG_NAME > /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.注意社区维基。

I tried this with Delphi XE.我用 Delphi XE 试过这个。 It didn't work until I figured out I needed to set the environment variables referenced by the .dproj file:直到我发现我需要设置.dproj文件引用的环境变量时,它才起作用:

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

I've had the same problem and found the solution:我遇到了同样的问题并找到了解决方案:

  1. Write /p:config instead of /p:configuration/p:config而不是/p:configuration
  2. Write "Release Build" or "Debug Build" (in double quotes) instead of Release or Debug"Release Build""Debug Build" (用双引号引起来)而不是ReleaseDebug

It did it for me.它为我做了。

Delphi 2009 uses build configurations . Delphi 2009使用生成配置 When you create a new project you have two default build configurations "Debug" and "Release".创建新项目时,有两个默认的构建配置“ Debug”和“ Release”。

Now I asked myself how to automate builds using MSBuild (which is supported by Delphi since version 2007).现在,我问自己如何使用MSBuild(自2007年以来的Delphi支持)自动进行生成。

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).您可以在某些Delphi项目目录的“ RAD Studio命令提示符”中启动“ msbuild”命令,它将构建默认的构建配置(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)! Delphi帮助断言该参数为[/ p:configuration = <configuration name >],这是错误的(Delphi 2009,帮助更新1)!

What is the right way?正确的方法是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM