This articles explains how you can use the Jazz Ant Tasks in the IBM Rational Team Concert (RTC) build for Microsoft Visual Studio (VS) projects or solutions. For integration support and requirements details please visit System Requirements
<?xml version="1.0" encoding="utf-8" ?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <AntCommand>C:\BuildToolKit\jazz\buildsystem\buildengine\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\bin\ant.bat -lib C:\BuildToolKit\jazz\buildsystem\buildtoolkit</AntCommand> <propertyFile>-propertyfile $(fetchDestination)\build.properties</propertyFile> <jazzbuildxml>-f $(fetchDestination)\TBDForm\TBDForm\build.xml</jazzbuildxml> </PropertyGroup> </Project>
Above
AntCommand uses the ant executable packaged with the Jazz Build Tool Kit.
propertyFile This file is automatically created when the Build is triggered. You can chose any location where you want this file to be created. By default , if you specify just the file name as "build.properties" in the Build Definition Microsoft Build tab, it gets created in the directory where jbe.exe resides. Check addition details in Setting up Build Definition in RTC section of this article.
jazzbuildxml is the file in which you will define the Ant Targets to build. See below.
Please note the paths mentioned above and in rest of article depends on where you save the files in your Visual Studio Solution or where they are located. In this article paths are used from the system where the setup was created. So replace the paths according to your setup.
<?xml version="1.0" encoding="utf-8" ?> <project name="jazz build targets" default="startActivity"> <property name="userId" value="jazzadmin"/> <property name="password" value="jazzadmin"/> <import file="C:\BuildToolKit\jazz\buildsystem\buildtoolkit\BuildToolkitTaskDefs.xml"/> <target name="startActivity"> <startBuildActivity repositoryAddress="${repositoryAddress}" userId="${userId}" password="${password}" activityIdProperty="buildactivityId" label="${activityLabel}" autoComplete="true" verbose="true" buildResultUUID="${buildResultUUID}" /> </target> <target name="publishActivity"> <tstamp/> <startBuildActivity buildResultUUID="${buildResultUUID}" label="${activityLabel}" autoComplete="true" repositoryAddress="${repositoryAddress}" userId="${userId}" password="${password}" verbose="true"/> <artifactFilePublisher repositoryAddress="${repositoryAddress}" userId="${userId}" password="${password}" buildResultUUID="${buildResultUUID}" filePath="${team.scm.fetchDestination}\TBDForm\TBDForm\bin\RTCBuildDebug\TBDForm.exe" label="TBDForm Debug Executable" verbose="true"/> <artifactFilePublisher repositoryAddress="${repositoryAddress}" userId="${userId}" password="${password}" buildResultUUID="${buildResultUUID}" filePath="${team.scm.fetchDestination}\TBDForm\TBDForm\bin\RTCBuildDebug\TBDForm.pdb" label="TBDForm pdb symbols" verbose="true"/> <linkPublisher repositoryAddress="${repositoryAddress}" userId="${userId}" password="${password}" buildResultUUID="${buildResultUUID}" url="http://www.ibm.com" label="www.ibm.com" verbose="true"/> </target> </project>
Find the following line the .csproj file
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Add the following line after it:
<Import Project="..\TBDForm\CommonProperties.xml" />
Location of the MSbuild property file depends upon where you have created it in the VS Project Directory.
There are two ways to achieve this.
Note: Do not make a copy of the other Build configuration. Create a new one from scratch. eg RTCBuildDebug.
Add Pre-Build and Post-Build Event to the MSBuild
if $(Configuration) == RTCBuildDebug ($(AntCommand) -DactivityLabel=Starting_$(AssemblyName) $(propertyFile) $(jazzbuildxml) startActivity)
if $(Configuration) == RTCBuildDebug ($(AntCommand) -DactivityLabel=Finished_$(AssemblyName) $(propertyFile) $(jazzbuildxml) publishActivity)
In essence the MS Build Pre/Post-Build event commands call Ant on the startActivity or publishActivity targets in the build.xml file. The if $(Configuration) == RTCBuildDebug condition ensures that those tasks are only executed if we invoke the build using the Jazz Build Definition which is using RTCBuildDebug build configuration to build the project. Thus allowing the user to run build natively within Visual Studio using Debug or Release or any other configuration that is not used by RTC Build Definition.
if $(fetchDestination) NEQ '' ($(AntCommand) -DactivityLabel=Starting_$(AssemblyName) $(propertyFile) $(jazzbuildxml) startActivity)
if $(fetchDestination) NEQ '' ($(AntCommand) -DactivityLabel=Finished_$(AssemblyName) $(propertyFile) $(jazzbuildxml) publishActivity)
jbe -repository https://server-vs.ibm.com:9443/ccm -userId jazzadmin -pass jazzadmin -engineId VS-Build-Engine -verbose
"msbuild.exe"
C:\Windows\Microsoft.NET\Framework\v4.0.30319
${team.scm.fetchDestination}\TBDForm\TBDForm.sln
RTCBuildDebug or Debug
${team.scm.fetchDestination}\Compiler.log
/property:fetchDestination=${team.scm.fetchDestination}
${team.scm.fetchDestination}
build.properties or ${team.scm.fetchDestination}\build.properties (The path is what you defined in CommonProperties.xml with propertyFile variable)
This is the location which you set in the Build Definition in Jazz Source Control tab for Load directory.
Add the Build engine that you have created above to this Build Definition under Supporting Build Engines section on Overview tab. This setup is now complete. You can now execute the Microsoft Visual Studio Builds from RTC which are going to use the Jazz Ant Task you used in build.xml.
Status icon key: