The VB6 activity can be used to run a VB6 compile within a TFS2010 Team build. In this example we aim to show the basic steps that are required to get the activity integrated into a build.
Note: There are alternative ways to build VB6 applications not using this activity that are documented in other blog posts
Before you can make use of any of the
TFS 2010 community build activities you have to make sure they are available for the build system and on your development PC. Instructions for this process can be found in the
ALM Rangers build guide or in the
StyleCop page of this wiki. This page assumes the VB6 activity is available in the developers build process workflow toolbox.
As this activity is a wrapper for the VB6 command line tool, VB6 must be installed on all TFS Build Agent PCs that could run the workflow.
Add the activity to the workflow
The VB6 activity should added to the workflow. Assuming you are modifying the default build process template, then the key is to replace the MSBuild activity in the ‘Compile the Project’ sequence, as shown below.
Note we also add an If test block on the return value of the VB activity to allow us to fail the build if any return code other than 0 is returned. This is a fairly simplistic usage of the return code if test; as it is inside the loop of compiles it only
really has the desired effect if only one project is being build. If you need to build multiple projects then modifying this if block will be required so it does a check after each project is built and stopping the build instantly.
To capture to the VB6 activity return code we need to create an Int32 local variable with the scope of the ‘Compile the project’ sequence
Using existing Arguments
The default process template takes a argument of ‘Items to Build’. We can use this to specify the VB project files we need to compile. Even though, by default, the file selection dialog defaults to only .SLN/.CSPROJ extensions.
It is also worth remembering most of the other options in the default template will have little meaning for a VB project e.g.there are are no MStest unit tests and nothing FxCop (Code Analysis ) can advise on. You my want to remove these options from the
Setting the Properties on the VB6 Activity
The only property that must be set is the ProjectPath, which can be set to the
localProject which is built from the Items to build list argument.
If you want to fail the build if there is an error compiling the VB6 project you need to handle the
ReturnCode (using the Int32 variable created above and setting the build property as failed if the return value is not zero)
You may also need to override the default path to the VB6.exe, especially if your build agent PC is 64bit (which is not a recommended platform)
The full set of properties available are.
||Path to VB6 compiler. Default is C:\Program Files\Microsoft Visual Studio\VB98\VB6.exe
||Default is build drop location + vb project directory (if the build is set to not copy files to a drops location then this parameter must be explicitly set)
||Default is build drop location + vb project filename + .log (if the build is set to not copy files to a drops location then this parameter must be explicitly set)
||The fully specified path to the VB6 project to compile
||Project properties to change at build time. Specify properties to change as key=value;key=value
||Gets the Return Code from the VB6 compile activity,
if not zero then an error occurred with the build
||Working directory used when compiling
Running the Build
When a build is run the VB project should be built and the .EXE placed in the drops folder.
Note that you will see the TF270003 error when the default workflow tries to copy the contents of the binaries folder, which has not been created by the compile sequence. This warning can be removed by editing the
OutDir, further editing of the workflow, or creating an empty folder with the correct name.
If you check the build log you will see the actual command run by the activity
Known Issues with Building VB6
- Building a VB6 project is not so difficult, but as you have to register the component, your build account must have suitable privileges on the build agent PC.
- You can't build simultaneously 2 builds with the same components because VB6 use the COM registration for the references.
- The most tricky part is to ensure binary compatibility during the build process.
- Also circular dependencies can happen quickly with a lot of VB6 components.
- You should also avoid using a 64bit build machine