简体   繁体   English

使用 MSBuild 自动构建 Delphi 2010 项目

[英]Automate Delphi 2010 project build with MSBuild

I'm looking to compile my Delphi 2010 project using MSBuild, but something isn't right, I just couldn't make MSBuild to compile my project.我想使用 MSBuild 编译我的 Delphi 2010 项目,但有些不对劲,我只是无法让 MSBuild 编译我的项目。

I tried this command line:我试过这个命令行:

"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe" "C:\\MyProject\\Myapp.dproj" /t:Release "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe" "C:\\MyProject\\Myapp.dproj" /t:Release

and this:还有这个:

"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe" "C:\\MyProject\\Myapp.dproj" /p:Configuration=Release /t:Release "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe" "C:\\MyProject\\Myapp.dproj" /p:Configuration=Release /t:Release

But MSBuild won't recognize my build configuration!但是 MSBuild 不会识别我的构建配置!

I also changed [ rsvars.bat ] but it didn't work!我也改变了 [ rsvars.bat ] 但它没有用!

@SET BDS=C:\Program Files (x86)\Embarcadero\RAD Studio\7.0
@SET BDSCOMMONDIR=C:\Users\Public\Documents\RAD Studio\7.0
@SET FrameworkDir=C:\Windows\Microsoft.NET\Framework\v4.0.30319
@SET FrameworkVersion=v4.0.30319
@SET FrameworkSDKDir=
@SET PATH=%FrameworkDir%;%FrameworkSDKDir%;%PATH%
@SET LANGDIR=EN

The MSBuild error is: MSBuild 错误是:

C:\MyProject\Myapp.dproj : error MSB4057: The target "Release" does
not exist in the project.

Any help to get me build my app with MSBuild would be greatly appreciated.任何帮助我使用 MSBuild 构建我的应用程序的帮助将不胜感激。

(Yes, I'm fully aware of tools like FinalBuilder, I just want to learn how to do this with MSBuild) (是的,我完全了解 FinalBuilder 之类的工具,我只是想学习如何使用 MSBuild 做到这一点)

Thanks!谢谢!

You need to switch the parameters.您需要切换参数。 The target parameter (/t) tells MSBuild which target to create.目标参数 (/t) 告诉 MSBuild 要创建的目标。 This can be either 'Make', 'Clean' or 'Build' (or a combination of those - seperate them with ';' in this case).这可以是“Make”、“Clean”或“Build”(或它们的组合——在这种情况下用“;”分隔它们)。

The property parameter (/p) forwards properties to the actual compiler.属性参数 (/p) 将属性转发给实际的编译器。 You can specify for example the configuration using /p:config=例如,您可以使用/p:config=指定/p:config=

So if you want to clean and then build a project using the release configuration, specify the paramters like this:因此,如果您想清理然后使用发布配置构建项目,请指定如下参数:

msbuild.exe "/t:Clean;Build" "/p:config=Release" Myapp.dproj

/p:Configuration=Release更改为/p:config=Release

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

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