Build Biztalk Deployment Framework Projects using TFS2010
The Biztalk Deployment Framework (BTDF) is a utility to help Biztalk administrators to easily output the Biztalk application, its components, configuration, and port bindings to an MSI package. Building Biztalk and BTDF projects can be automated using TFS Team Build because those projects are built using MSBuild. In TFS 2010, Microsoft changed the team build template from MSBuild configuration file to Workflow (WF4) activity. I have seen many posts asking how to use TFS Team Build to build BTDF projects but yet no one blogged about it. In this post, I will be modifying the default TFS2010 Team Build Template to support building BTDF msi packages.
Creating new Team Build Definition
- Right click on one of the Teambuild definitions
- Click New Build Definition

- Enter the name of the build definition

- Fill the Trigger, workspace and build default sections
- Click on Process on the left
- Click on Show Details
- Click the New button
- Click browse next to “Select the file to copy”
- Select the Default Template, you can select the template you want to modify

- Give it a name; I am naming it BTDFBuildProcessTemplate
- Click Ok
- In the Required group, click the ellipsis next to Items to Build
- Add the solution you need to build which contains your Biztalk project(s)
- Add the BTDF project you need to build, make sure that you switch the Items of type to *.*proj

- Make sure that the solution is built first then the BTDFProj
- Click the Configurations tab
- My solution contains X86 and Any CPU projects, therefore I am choosing “Mixed Platforms”

- Click OK
- For this post, I am not running unit tests. Thus, I cleared the Automated Tests property
- Change the MSBuild Platform to X86, otherwise Biztalk projects will fail

- Save the build definition
- Close the Team Build Definition.
- Open Source Control from Team Explorer
- Browse to the BuildProcessTemplates folder
- Get latest version of the template we just created

Changes to the Default Template to Build Deployment Framework Projects
In this section, we will be modifying the workflow template we created in the previous section. Team build is different than building the solution from the visual studio. Team build creates two folders: one for the source files and one for the output called binaries. .btdfproj references biztalk dlls using a relative path which will be invalid when building the btdfproj using team build. We have two options, either to maintain the project structure and output the binaries to the source folder or add a condition to the .btdfproj to get the file from a different location when using Team Build. In this post, I will output the files into the bin folder in the source folder. This approach will affect your unit tests if you are running unit tests as team build checks the dlls in the binaries folder. It also affects copying the binaries to the drop folder. Another modification needs to be done to get this working. I will write another post to do such adjustment. The following steps adds activities to build the solutions and BTDF projects. The binaries of the projects will be output into the bin folder of each project in the source folder
- Open the BTDFBuildProcessTemplate.xaml workflow xaml file created in the previous section
- Click Collapse All

- Expand On Agent

- Expand the follow activities:
- Try Compile, Test, and Associate Changesets and Work Items
- Sequence
- Compile, Test, and Associate Changesets and Work Items
- Try Compile and Test
- Compile and Test
- For Each Configuration in BuildSettings.PlatformConfigurations
- Compile and Test for Configuration
- If BuildSettings.HasProjectsToBuild
- For Each Project in BuildSettings.ProjectsToBuild
- Try to Compile the Project
- Compile the Project
- Add a condition to check the type of the project to build by added an If activity between “Convert Server patch to Local” and “Run MSBuild for Project”

- Drag and drop the “Run MSBuild for Project” to the Else section

- In the If condition, check if the project extension is .btdfproj by entering the following condition:
IO.Path.GetExtension(localProject).Equals(“.btdfproj”)

- Change the OutDir property to “” to output the binaries into the bin folder in the source directory. Thanks to Ajith

- Change the Display name of the if activity to something meaningful

- If the project is a biztalk deployment framework project (*.btdfproj),
- Add a new MSBuild activity to the If body, and rename it to Build BTDF Msi’s

-
- Run msbuild (Build BTDF Msi’s activity) with the following arguments; we have set OutDir to “” to output the binaries into the source folder directory instead of the binaries folder.

- Save the workflow and close it
- Go to Source Control àBuildProcessTemplates
- Checkin the workflow that was modified

- Queue a new build
- After the build is done, you will find the projects’ executables and BTDF msi in the bin folder of each project
Hi,
You replied to my post on TFS Forums about automating an obfuscated build. I’ve modified the default process templete to include my .saproj file to build. I get the following error when I attempt to run the automated build:
C:\Builds\39\Manitou\DBManager\Sources\Releases\1.6.0\Fixes_1.6.0\DBManager\RepSwitch\DBManager.saproj (1): The element is unrecognized, or not supported in this context.
Any idea on what I need to add to get this working?
Have you added an if statement to the templete to check if it is .saproj to run Invoke process activity with C:\Program Files\Red Gate\SmartAssembly 5\smartassembly.com” /build BinariesDirectory localProject /markasreleased ?
Make sure you duplicate the template.
I setup the InvokeProcess in the “Then” statment of the “If”. Do I simply put “C:\Program Files\Red Gate\SmartAssembly 5\smartassembly.com” /build BinariesDirectory localProject /markasreleased
in the Arguments of the InvokeProcess?
Thanks!
I am not really familiar with smartassembly.com command arguments. You actually don’t need the Binaries directories, replace “$(ProjectDir)DBManager.saproj” with localproject. localproject is a variable that contains a reference to the project you added in the list under the process page in build definition. Is there an argument to set the output folder on the smartassembly.com? If yes, you need to set the output to be the BinariesDirctory
I’ve done as you have advised.
My arguments are: “/build BinariesDirectory localProject /markasreleased”
Filename is: “C:\Program Files\Red Gate\SmartAssembly 5\smartassembly.com”
When I now try to fire up the project it builds successfully, but I get the following warning:
TF270003: Failed to copy. Ensure the source directory C:\Builds\39\Manitou\DBManager\Binaries exists and that you have the appropriate permissions.
The binaries directory is completely missing now, and it appears that the .saproj was not executed. Any ideas on why that may be?
In your team build definition, How many projects do you have there? Do you only have the saproj file? Try removing the BinariesDirectory from the arguments.
Is there anyway to set the output directory of smatAssembly.com?
There is an “Output” parameter I can use to set smartassembly output. I’ve added into the parameters but it is still not building the Obfuscated.exe.
I will have to get back to you on this tonight or tomorrow morning. I will install the trial version and get familiar with the tool then test it with team build. Cheers.
Hi Larry,
I installed the tool. You don’t need to modify the workfolow. You need to edit the project file.
Right Click on the project –> Unload project
Right click on the project–> Edit project
If you are using VB, after the following line:
Add
<UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName="SmartAssembly.MSBuild.Tasks, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57" /> <Target Name="BeforeBuild" Condition=" '$(Configuration)' == 'Release' "> <CreateProperty Value="true"> <Output TaskParameter="Value" PropertyName="RunSmartAssembly"/> </CreateProperty> </Target> <Target Name="AfterBuild" Condition=" '$(RunSmartAssembly)' != '' "> <SmartAssembly.MSBuild.Tasks.Build ProjectFile="SmartAssemblyPOC.saproj" input="$(OutDir)SmartAssemblyPOC.exe" output="$(OutDir)SmartAssemblyPOC.exe" OverwriteAssembly="true" MarkAsReleased="true"/> </Target>Hi,
Great post, however in the part where you specify the commandline parameters you will loose the ability to use additional MSBuild properties, i suggest to alter it to use:
String.Format(“/p:SkipInvalidConfigurations=true /t:Installer {0}” , MSBuildArguments)
see: http://biztalkdeployment.codeplex.com/discussions/226299
I agree with you. It is implemented as you said except the screen shot is outdated. I didn’t have access to the same server when I wrote the article.
Good catch and others can benefit form your comment.
Thanks
Ahmed
I have setup my solution to mirror yours but when it is running on the TFS build server it tries to see if the application is installed already. Is there any way for only the MSI to be created on the build server without it looking to see if it is installed already?
Thanks
Sorry for the delay. Is it still an issue? t is been a while since I worked on this. I will get back to you
I have applied all the steps specified here ..and the tfs build completes successfully but when I go to the drop folder I dont see anything other than logs folder. Where should i look for the msi?
It should be in the binaries folder and the drop folder.
BizTalk literally slows down the rate at which it processes messages.