Build using DCC32.exe in delphi - delphi

Hello I am building my delphi project using the following command:
Command: dcc32.exe project.dpr d:\exe_folder
The above command works good and I am able to cerate the exe in output folder. But when I build same project through IDE then on each build the build number is incremented as there is option 'Auto Increament Build Number' which I have checked. But while doing it through command line the build number is not getting increasing. Any option to revise the build info/version info through the command line??
Thanks..

dcc32.exe can't increase build number directly. Version info (including build number) is used from *.res file which is updated every time by IDE. To bypass IDE you can write RC script with version info section, small app that will increase build number in this script. Then, you can create bat file with the following actions for building:
Run your app to increase build number
Compile RC script using brcc32.exe (in - RC script, out - RES file)
Compile your application with dcc32.exe with new .res file
P.S. Don't forget to include RES file with version info to your project:
{$R "yourversioninfofile.res"}

No, the auto increment of the build number is an IDE feature. You will likely need to script your own auto increment facility using an appropriate scripting language.
If you wanted to use your own command line auto increment alongside the IDE's equivalent, here's what you'd need to do:
Get your script to read the .res file that is managed by the IDE.
Increment the build number.
Re-create the .res file.
Build the project.
To make this work I think you'd need to reverse engineer what's in the IDE generated .res file. But that's pretty easy. Any decent resource editing tool will help you do that.

That's what I wrote dzPrepBuild for.

Related

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.

MSBuild and multiple Delphi versions

I have a project for which I need to build two executables: one under Delphi XE2 and one under XE3. I have a build script which builds each version (i.e. one script for XE2 and one for XE3).
If I run the build script for the last version of the IDE I ran, all works well (i.e. run Delphi XE2, build app, run XE2 build script).
However if I run the build script having just run a different version of the IDE I get an AV as soon as my app starts (I.e. run Delphi XE2, built app, run XE3 build script).
It looks as though something about the build script is being cached/modified by the IDE and I need to restore the appropriate data for the version I want to build with. I've tried this with the .dproj, but no luck.
Or could it be loading form resources - both editions show errors due to non-existent properties at start up if the IDE. If so, is there an easy way around this without having maintain multiple versions of all the .fmx files?
Here's a sample build script:
set path=%path%;c:\Windows\Microsoft.NET\Framework\v3.5
set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\10.0
set path=%path%;c:\Documents and Settings\All Users\Documents\RAD Studio\10.0
set BDS=c:\Program Files (x86)\Embarcadero\RAD Studio\10.0
set FrameworkDir=c:\Windows\Microsoft.NET\Framework\
set FrameworkVersion=v3.5
set failed=false
cd \myprogs\monkeystyler
msbuild monkeystyler.dproj /t:build /p:config=full||set failed=true
cd build
if not %failed%==true goto Done
echo ****FAILED TO BULD MONKEYSTYLER
****
Pause
exit
:done
Let's take a look at this line in your XE3 script:
set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\10.0
My guess is that you follow that up in the XE2 script with:
set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\9.0
At which point your path variable looks like this:
set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\10.0;c:\Program Files (x86)\Embarcadero\RAD Studio\9.0
And so the second script fails because the paths from the first script appear earlier.
The elegant way to fix this is to use setlocal and endlocal in your scripts to isolate them from each other.
setlocal
set path=%path%;c:\Windows\Microsoft.NET\Framework\v3.5
set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\10.0
.....
endlocal
The hacky way to fix it is to set the path like this:
set path=c:\Program Files (x86)\Embarcadero\RAD Studio\10.0;%path%
Please use the elegant approach!
What's more you should use pushd and popd to isolate directory changes to each script.
If this doesn't solve everything, do give more information. For a start, error messages are very useful.
The last IDE that you run will update the EnvOption.proj in your <user>\AppData\Roaming\Embarcadero\BDS\<version>folder.
This contains all your search paths, among other things.
This file is indirectly included in your project. So if you run say XE2's IDE then compile your XE3 app, you will get the wrong paths.
You will probably want to disable that and explicitly specify your search paths in each project's dproj file.
e.g. msbuild myproj.proj /p:ImportEnvOptions=false
This is my best guess. Sorry if it's 5 years too late. I have just struggled with similar issues!
All the best
Steve
I went back to my suspicion that it was the form file resources.
My theory was that the with the form files saved by the 'wrong' version of the IDE, when a project built with a different version tried to load them I was getting access violations due to the app trying to load data for properties which where not available in that edition.
To test this I got compiled the project successfully in one version of the IDE (XE3 in this case), did my automated build and tested that the app ran (it did).
I then loaded a .fmx file for the project and added a non-existent property to the form.
Build and the app fails same as before.
Remove the added property and build now succeeds.
All (!) I need to do now is write some code to parse the form files and remove any non-existent properties for the version I'm building.

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)

Howto Force TFS 2010 to build a website using the 32bit ASPNET Compiler on a 64 bit build machine

We have a very large product that compiles just fine on our 32 bit build controllers and mostly on our 64 bit build controllers with one exception. We have a precompiled web forms front end. When it builds on the 64 bit machine it shows a command line in the log file of
*C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v /ourwebapp -p ..\ourwebapp\ -u -f "........\Binaries\Mixed Platforms_PublishedWebsites\ourwebapp\"*
This causes an error because of some 32 bit third part dll's we have:
ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'Leadtools.Codecs' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\Builds\5\OurApp\OurApp Build\Sources\Product\Solutions\ourwebapp_ourwebapp.metaproj]
Does anyone know the correct solution file syntax to force a 32 bit build regardless.
Thank you.
Edit you Build Definition and select this option.
Process Tab-> Advance->MSBuild Platform->X86
Save your build and trigger the build ...
Erik, if you edit your build definition, under the process tab there is the option to set the msBuild compilation x86 or x64 or Auto, setting this to x86 would force the build to perform the compilation in 32 bit.
In the Configurations to Build box, you can specify which platforms and configurations you want to build. (To show this box, expand the Required node, and then expand the Items to Build node.) For example, you can specify that this build should build only the release configuration of the 32-bit version of your C++ project by including Release|x86 in this box. If you leave the Configurations to Build box empty, the default configuration and platform that is defined in each solution or project is built.
See the steps here. http://msdn.microsoft.com/en-us/library/dd647547.aspx

Resources