delphimsbuildbuild-script

HowTo build a delphi application with MSBuild and a compiler included into the respository (not installed with IDE)


My question is if the following scenario is possible.

  1. I have a system (maybe a Docker image) where MSBuild is installed.
  2. I have a repository which contains my sourcecode (Delphi) and the delphi compiler (directory bin and lib).
  3. Now I checkout my repository on that system and want to use msbuild to build my application and msbuild should use the compiler from my repository.

The idea behind this is, to have all data in one place which is needed to build my application (sourcecode, resources, compiler, build scripts ...). And I wanted to use MSBuild because there I can build the .dproj file than the .dpr file (with dcc) which contains less information (e.g.: search path).


Solution

  • In the BIN folder there is a file called RSVARS.bat that sets up the required environment variables. When you clone your repository containing the BIN/LIB folders to your build machine, you should take into account the required paths and either create a new rsvars.bat or update this file as required.

    You can then just run something like this to build your project:

    msbuild projectname.dproj /t:build /p:Configuration=Release /p:platform=Win32
    

    I've recently gone into some detail on this covering Jenkins and Delphi builds in a blog post. You can skim the Jenkins parts and just refer to the command line build info, mainly the "Configure A Delphi Build Agent" and "Notes on Using MSBuild on Delphi Projects" sections: https://www.ideasawakened.com/post/getting-started-with-ci-cd-using-delphi-and-jenkins-on-windows