I am trying to build a delphi project in TeamCity, but I can't get it to work.
I'm using MSBuild to build the project and also have added BDS parameter to the build but I keep getting the error: MSB4040 There is no target in the project.
There are several things you need to be aware of. Firstly, the various environment variables and paths that Delphi requires need to be setup. Much of this is accomplished by the rsvars.bat batch file, but you can set up your own. Secondly, your EnvOptions.proj file needs to be set correctly to match the environment on your build machine. This file resides in %APPDATA%\Embarcadero\xx,x\ where xx.x is your Delphi version.
The following commented CMD file is one that I use to build Delphi XE7 applications in a TFS environment and should work with TeamCity and other build tools :-
#echo off
:::
::: Example for Build Delphi Project with MSBuild
:::
echo.
echo using MSBuild from VStudio 2013
echo.
SET MSBUILD_EXE=C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe
echo.
echo A copy of a Delphi installation from a developers machine is ok. MSBuild calls dcc32/dcc64, not the IDE.
echo The build targets are included in "$(DelphiInstallDir)\bin\CodeGear.Delphi.Targets".
echo DefaultTarget is "Make"
echo.
echo.
echo Set Delphi XE7 Vars
echo.
SET BDS=C:\DelphiXE7
SET BDSBIN=%BDS%\bin
SET BDSLIB=%BDS%\lib
SET BDSTMP=%BDS%\Temp
echo.
echo On a local Delphi developer machine the actual used Delphi settings are located here:
echo "%APPDATA%\Embarcadero\BDS\15.0\EnvOptions.proj"
echo.
echo The directories and files included in "EnvOptions.proj" must exist on the build machine!!!
echo.
echo Copy the (maybe modified) Delphi settings on your build machine to %APPDATA%\Embarcadero\BDS\15.0
echo.
MKDIR "%APPDATA%\Embarcadero\BDS\15.0"
COPY /Y /B /V "%BDSTMP%\EnvOptions.proj" "%APPDATA%\Embarcadero\BDS\15.0\EnvOptions.proj"
echo.
echo Set the Delphi Project Vars
echo.
SET PROJECT_SRC=C:\MyProjectSource
SET PLATFORM=Win32
SET CONFIG=Debug
echo.
echo Build Delphi Project with MSBuild
echo.
echo + /p = Parameters for the Delphi Project Build
echo.
echo + /t = Targets to be executed, e.g. Clean and Build
echo.
"%MSBUILD_EXE%" "%PROJECT_SRC%\myProject\myProject1.dproj" /p:Config=%CONFIG%;Platform=%PLATFORM% /t:Clean;Build
IF NOT ERRORLEVEL 0 GOTO ERROR
GOTO END
:ERROR
echo.
echo There were errors!
echo.
pause
EXIT
:END
pause
You could correct setup teamcity to build using MSBuild using the follow steps:
First you should define the parameter on teamcity that declares the enviroment variables that is seted by rsvars.bat, to do that in your Project access the Parameters and create a new configuration, select the type enviroment variable, set the same names and values from the rsvars.bat file aka: BDS, BDSCOMMONDIR, et all.
After that in you msbuild step edit the target option to "build".
You can see that this information is documented here http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Building_a_Project_Using_an_MSBuild_Command
Here you can see my params configuration
And here is the MSBuild Project configuration
Related
I'm currently trying to set up a build process on a build server and I'm having some trouble installing JEDI with MSBuild. I'm using the Delphi XE2 compiler and based on this Stackoverflow thread I have created the following batch file that I use.
#echo off
:::
:::Build Delphi Project with MSBuild
:::
echo.
echo Setting up Delphi XE2 environment
echo.
SET BDS=C:\DelphiXE2
SET BDSBIN=%BDS%\bin
SET BDSLIB=%BDS%\lib
SET BDSTMP=%BDS%\temp
SET BDSAPPDATA=%APPDATA%\Embarcadero\BDS\9.0
IF NOT EXIST "%BDSAPPDATA%" MKDIR "%BDSAPPDATA%"
COPY /Y /B /V "%BDSTMP%\EnvOptions.proj" "%BDSAPPDATA%\EnvOptions.proj"
echo.
echo Build Delphi Project with MSBuild from Visual Studio 2017
echo.
SET MSBUILD_EXE=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
"%MSBUILD_EXE%" %1 /t:%~2 /p:Config=%~3;Platform=%~4
I then call
compile.bat ".\Jedi\JCL\packages\JclPackagesD160.groupproj" "Clean;Build"
which works fine (atleast without any errors) and after that
compile.bat ".\Jedi\JVCL\packages\D16 Packages.groupproj" "Clean;Build"
But the second call fails because jedi/jedi.inc can not be found. What am I doing wrong?
Check the .dproj file(s). Is the subdirectory containing the jedi.inc file included in the search path? Is the file actually there? (It used to be in its own svn repository on sourceforge and included as an svn:external. No idea how they have solved this with git nowadays.)
I am facing the error below during configuration of MSBuild in Jenkins:
[ImageResize] $ cmd.exe /C " msbuild.exe p:Configuration=Release
E:\Heena\Applications\ImageResize\vbimage\ImageResize.sln " && exit
%%ERRORLEVEL%% 'msbuild.exe' is not recognized as an internal or
external command, operable program or batch file. Build step 'Build a
Visual Studio project or solution using MSBuild' marked build as
failure Finished: FAILURE
Please note that I have set MSBuild path up to msBuild.exe during setting up of MSbuild plugin. I have successfully deployed Visual Studio project on jenkins, but unable to configure it with MSBuild.
In MSBuild installations option of jenkins,
Choose the path to MSBuild = C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Then go to your respective jenkins project where you want to build,
from,Add Build Step menu choose
Build Visual Studio Project or solution using MSBuild option
MSBuild version will be what you defined in Step 1 and in MSBuild File
type the path of your solution file and in Command Line Arguments option
type /p:Configuration=Release.
Hope you got the answer what you were looking for.
A Guess from my side , msbuild.exe is not part of the PATH when you execute the msbuild command , check that before you run the command , try to export the the path to msbuild to the path variable.
Looking at the error i assume you are using windows/Batch , so try some thing like this before running msbuild
set PATH=%PATH%;path/to/msbuild/binary
Feel free to revert in case of any issues/concerns
i am trying to execute devenv.exe through windows batch command plugin in Jenkins
but it keeps on executing and fails to launch the application.
Console Output :
**In progressConsole Output
Started by user anonymous
Building on master in workspace C:\Program Files (x86)\Jenkins\jobs\TEMP\workspace
[workspace] $ cmd /c call C:\Windows\TEMP\hudson3900292017086958332.bat
C:\Program Files (x86)\Jenkins\jobs\TEMP\workspace>set DEVPATH=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
C:\Program Files (x86)\Jenkins\jobs\TEMP\workspace>set PATH=D:\app\nazopay\product\11.2.0\dbhome_1\bin;D:\app\nazopay\product\11.2.0\client_1;C:\Program Files (x86)\Integrity\IntegrityClient10\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\cde\tools;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_23\bin\;C:\Program Files (x86)\Google\Chrome\Application;C:\MingW;C:\PROGRA~2\INTEGR~1\Toolkit\mksnt;%JAVA_HOME%;,;C:\Program Files\Java\jdk1.6.0_23;,;C:\Program Files\Java\jdk1.6.0_23\bin;%CLASS_PATH%;,;C:\Program Files\Java\jdk1.6.0_23\lib;,;C:\Program Files\Java\jdk1.6.0_23\lib;;C:\Program Files (x86)\M**icrosoft Visual Studio 10.0\Common7\IDE
C:\Program Files (x86)\Jenkins\jobs\TEMP\workspace>devenv.exe
You must execute devenv.com.
The devenv.exe always attempts to open GUI, even when commands are given, and it can't. The devenv.com has output directed to standard output and works fine from Jenkins.
You also must pass arguments.
Without arguments both devenv.com and devenv.exe just start the IDE GUI, which is not what you want. The correct command-line is
devenv.com projectname.sln /Build Release /Project projectname
First is path to the solution you want to build. Then the /Build flag is followed by configuration. If you have multiple platforms, you have to pass configuration and platform combination, e.g. Release|Win32. The /Project flag names project to build (including all dependencies). If omitted, it builds all projects selected for build in given configuration.
Why don't you use msbuild?
This would be a good starting point for your windows build script:
call "%VS100COMNTOOLS%\vsvars32.bat"
msbuild projectname.sln /target:Rebuild /l:FileLogger,Microsoft.Build.Engine;logfile=msbuild.log || goto error
goto end
:error
#echo ERROR: Build failed
exit/b 1
:end
exit/b 0
This way you can also capture the output log that you can parse with one of the jenkins plugins.
Ofcourse, adjust the VS100COMNTOOLS to your version of MSVS
i have downloaded the Ant distribution from the Ant web site.
apache-ant-1.7.0
and set environment variable specifying the location of the Ant installationas
ANT_HOME = C:\portal\apache-ant-1.7.0
PATH=;%ANT_HOME%\bin
But ant is not getting properly installed
Better use batch or shell scripts to start your ant files, f.e. =
windows
set JAVA_HOME=C:\java\jdk\1.6.0_xx
set ANT_HOME=C:\ant
set ANT_ARGS=-lib C:\ant_xtralibs;C:\ant_testlibs
set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin;C:\cvsnt
:: default
call ant -f %1
:: debug
::call ant -debug -f %1
...
unix - don't forget the quotationmarks on the ANT_ARGS line !
...
ANT_ARGS="-lib /usr/local/ant_xtralibs:/usr/local/ant_testlibs"
export ANT_ARGS
...
Some advantages of starting ant like that :
ANT_ARGS is a special environment variable. Its content is automatically
added to the invocation of ant.
you may use your own ant settings on a machine where you have no admin rights
using a separate folder for your ant addon libs and load via -lib option
keeps your ant installation clean and avoids polluting the %ANT_HOME%/lib folder
Move the ';' to the end. Be sure that java is also correct installed (variable for classpath, etc.)
Depending on you verson of windows (win2k & win XP), you might need to reboot your computer to make your PATH modifications taken into account.
Delphi 2009 uses build configurations. When you create a new project you have two default build configurations "Debug" and "Release".
Now I asked myself how to automate builds using MSBuild (which is supported by Delphi since version 2007).
You can start the "msbuild" command in the "RAD Studio Command Prompt" in some Delphi project directory and it will build the default build configuration (the last activated build configuration inside the Delphi IDE).
Now, I want to specify a certain (non-default) build configuration by a command line parameter.
The Delphi help asserts that the parameter is [/p:configuration=<configuration name>], which is wrong (Delphi 2009, Help Update 1)!
What is the right way?
Now, if you want to change the build configuration you have to add the parameter
/p:config=<BUILD_CONFIG_NAME>
For example:
C:\Projects\TestDelphiApp001>msbuild /target:Build /p:config=Release
or
C:\Projects\TestDelphiApp001>msbuild /target:Build /p:config=Debug
Copied from original "question"; note community wiki.
I tried this with Delphi XE. It didn't work until I figured out I needed to set the environment variables referenced by the .dproj file:
SET BDS=C:\Program Files (x86)\Embarcadero\RAD Studio\8.0
SET BDSBIN=C:\Program Files (x86)\Embarcadero\RAD Studio\8.0\bin
SET BDSAPPDATABASEDIR=BDS
msbuild myproject.dproj /target:Build /p:config=Release
I've had the same problem and found the solution:
Write /p:config instead of /p:configuration
Write "Release Build" or "Debug Build" (in double quotes) instead of Release or Debug
It did it for me.