Sunday, April 27, 2014

Building Delphi VCL Packages From the Command-line Using PowerShell and MSBuild - Part 2

This is part 2 of the series, continuing from part 1.

MSBuild Prerequisites

MSBuild is installed along with the .NET framework, so I knew it was already on my computer.

The next thing I needed to do was to figure out how to compile a project using MSBuild. So, I started by opening a command-prompt, navigating to my ZLibEx package, and running:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe ZLibEx_XE2.dproj

It failed with the following error:

C:\VCL\ZLibEx\ZLibEx_XE2.dproj : error MSB4040: There is no target in the project.
Of course, there probably needed to be some environment variables defined.  So, I looked at the shortcut properties for the RAD Studio Command Prompt shortcut on my start menu. It ran a .bat file that registers some environment variables that were located at:
C:\Program Files (x86)\Embarcadero\RAD Studio\9.0\bin\rsvars.bat
Next, I cracked open that .bat file to see what the magic vars were. I thought the following lines looked important:
@SET BDS=C:\Program Files (x86)\Embarcadero\RAD Studio\9.0
@SET BDSCOMMONDIR=C:\Users\Public\Documents\RAD Studio\9.0
@SET FrameworkDir=C:\Windows\Microsoft.NET\Framework\v3.5
@SET FrameworkVersion=v3.5
 So, I pasted each one of those in at my command prompt. I then ran my initial command one more time:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe ZLibEx_XE2.dproj
It compiled successfully!

Part 3

No comments:

Post a Comment