Sunday, April 27, 2014

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


Introduction


Three years ago, feeling concerned about the future of Delphi, I left my Delphi position in favor of a C# position. I soon found myself working in a Configuration Management / DevOps / Internal Tools Developer role. During this time, I was required to master MSBuild technologies. One of my responsibilities was to automate the build and deployment of thousands of projects on a daily basis.  Needless to say, I learned the ins and outs of MSBuild.

A little over a year ago, I opened up Delphi. It brought back memories of my 11-year long career in Delphi. Some of them were good. Some of them were bad.

One of the worst memories it brought back was that of installing VCL packages. To be able to open up one of my Delphi projects, I remembered that I would first have to manually compile and install over 15 VCL packages. Some of those consisted of multiple VCL projects.

I remembered this used to take my over 16 hours to complete in the past. Being a DevOps professional at my new full-time job, I wanted to tackle this he right way. I was going to automate the installation of my VCL packages from the command-line.

Being very familiar with PowerShell, I decided to build a PowerShell module that was capable of automatically building my VCL dependencies from the command-line. My first attempt was to use the DCC.exe compiler. After sixteen hours of labor and discovering undocumented "features" the hard way, I finally managed to compile my entire VCL.

Thinking I had done something amazing, I shared the project with my former team. Being the Delphi control-freaks they are, I could tell the thought of doing anything related to code in an automated fashion was very difficult to accept! But, I was persistent. Before long, one of them even set up a Jenkins server. I was impressed. It was around that time that I enrolled in school.

Now, here I am a year later, revisiting Delphi. I first decided to check on my script. I ran it with the latest source. It failed to compile!  It was failing because somebody had added a CodeSite dependency to one of my VCL packages.

Exploring around the file system to find a solution to my dilemma, I happened to open a .dproj file.  Lo and behold, it was an MSBuild project! I had been working in Delphi for 11 years, and did not even know what MSBuild was! Now I had a new objective: Update my PowerShell scripts to compile my VCL packages in Delphi using MSBuild instead of DCC32 and DCC64. I will report my progress in future parts of this series.

Part 2

No comments:

Post a Comment