How can I perform a 'dry run' of MSBUILD for a Delphi project? - delphi

if I launch the RAD Studio command prompt and run
msbuild /t:Rebuild
in the project directory, msbuild will show the full command line to invoke dcc32, including all path settings. (see Is there a Delphi library which returns all effective source paths for a project?)
If I only want to capture this msbuild console output in a file, and do not need the compiler execution, is there a way to run msbuild only to display which actions it will perform? I have checked the msbuild options but there seems to be no 'dry run' switch.
One possible (but amateurish) solution could be to modify the PATH so that msbuild will not find the compiler.

You can replace dcc32.exe with your own application which will log the command line and exit.

I don't think this is possible. Also I don't think that you will have success by modifying the PATH variable. As far as I knwo the CSC task will not use that to locate where the csc.exe is located.

Related

Delphi XE - Fatal: F1027 Unit not found: 'System.pas' or binary equivalents (.dcu)

During compilation of Delphi project, following error is given by the compiler:
Fatal: F1027 Unit not found: 'System.pas' or binary equivalents (.dcu)
This happens only when building though msbuild using TFS build system.
Works fine when executed through command line as below.
Command:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\msbuild.exe E:\Src\Project\sample.groupproj /v:m /t:Build /p:Config=Release
The following execution through MSbuild fails:
<Exec Command="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\msbuild.exe E:\Src\Project\Sample.groupproj /v:m /t:Build /p:Config=Release"/>
Note:Following env variables are set : BDS,BDSLIB,BDSCOMMONDIR,BDSINCLUDE
When executed through CCNET dcc32.exe has extra arguments such as -I,-LE,-LN,- O,-R,-U,-NB,-NH,but execution through TFS does not have the these argument list.
Any thoughts on how to resolve these errors.
Thanks in Advance....
It is possible that your environment is not configured properly. First call the RSVARS.BAT file located in the BIN directory of your Delphi installation prior to calling msbuild.
If you are calling this from another build system, my suggestion would be to create a simple batch/cmd file that will call RSVARS.BAT followed by executing MSBUILD and have your build system invoke that instead.
If you try to invoke RSVARS.BAT separately, it will modify its copy of the environment then exit, which will effectively do nothing to the parent environment. Adding a call to RSVARS.BAT from within the MSBUILD script will also fail for the same reason. The RSVARS.BAT must be called from the same contextual environment (or higher) as the MSBUILD task.

Jenkins - Run exe and check output

I am new to Jenkins, so my question is really simple.
I would like to run an exe and check if the output text file is as expected.
So:
Grab the artifact the SVN (OK!)
Run and exe with some command line arguments (OK!)
Check the output text file (Don't know how to do it)
Any help?
Bonnus: Instead of running an .EXE located in SVN, is there a way to build the C# .NET code to generate the release .EXE ?
You can check the contents of the output file using any scripts. I used NAnt's loadfile to load the whole file. I am sure that there will be an ANT version of loadfile task too.
http://nant.sourceforge.net/release/0.85-rc1/help/tasks/loadfile.html
Regarding the second question, you can use the MSBuild plugin to compile your code and generate the Release exe. There are parameters which you can pass to MSBuild to do it.

Will the dcc32.exe compiler use project build configuration file when is called with --no-config parameter?

Problem description:
Consider the following command line call (called for Delphi 2009 compiler):
dcc32.exe --no-config --peflags:1 Project.dpr
Will this call use the Project.dproj or Project.dof configuration files ?
If yes, will the command line options take precedence over the configuration file(s) ?
If not, where the build configuration will be taken from if the dcc32.cfg file is not loaded in this case ?
Problem background:
I know that MSBuild should be used since Delphi 2007 but in fact, it's the reason why I'm asking. I found that InnoSetup uses this batch file for building its projects and I have serious problems to link the JEDI JVCL library to it (it's a pure nightmare). So I'd like to configure the project settings to use MSBuild, but I'm not sure what build settings are used in the above command line call.
--no-config means that dcc32.cfg is not loaded, neither from the compiler executable directory, nor from the project directory.
The rules for applying options specified in .dproj and .dof files are not affected. Those options are applied and any command line options take precedence.

Is it possible to run the command line compiler with selected build configuration in Delphi XE2?

I'd like to make builds from the command line and I'm wondering if there's a way how to execute the command line compiler with selected build configuration ?
I know there is option --no-config which won't load default dcc32.cfg file but I would like to set the build configuration I've prepared in my project.
I would like to run something like
dcc32.exe --some-option RELEASE Win32 PLATFORM
Is there some option for selecting build configuration ?
Thank you
You need to be using msbuild rather than dcc32 for this:
msbuild myproject.dproj /p:Config=RELEASE;Platform=Win32
Make sure you have called the rsvars.bat file from the RAD Studio bin folder before you attempt to call msbuild. This sets up the necessary environment variables.
The great thing about the modern msbuild based build system, as implemented in Delphi, is that you can quite easily ensure that your command line builds are identical to your IDE builds.
As far as I know, you can use the dcc64.exe to compile for 64-bit if you do not want to use MSBuild. It is in the same folder as the dcc32.exe (and dccosx.exe for compile for OSX)

Running Delphi builds under TFS MSBuild

Wanting to build and test a bunch of Borland Delphi 6 projects that are integrated with ASP.NET services. Had been using WANT and CruiseControl for building Delphi. With TFS Build agent we can tie all together and do some testing. I am looking for guidance and direction.
One issue I see is that there is no "solution" in a Delphi project to be given to MSBuild as a '<'SolutionToBuild'>'.
<SolutionToBuild Include="There is no such thing as a Delphi.sln">
<Targets></Targets>
<Properties></Properties>
</SolutionToBuild>
Also, I have references to <UsingTask> but am a little unsure how to use them. The <UsingTask> allows run custom task for Delphi command-line compile.
Your guidance would be appreciated.
Can you upgrade? Delphi 2006+ uses MSBuild by default. There is nothing to configure.
You can use MSBuild to run the Delphi command line compiler. It's been a while, but I'm pretty sure either the IDE supports command line compilation or there is a stand-alone compiler that can be run from the command line. In either case, you would need to create an <Exec> task that runs the appropriate command line build tool with the required parameters.
When you say you have "references to <UsingTask>" do you mean that you are importing an external MSBuild task? The <UsingTask> element is used to pull in a custom MSBuild task that resides in an external assembly (DLL). Once the task is imported, you use it just like you would any other built-in task.

Resources