MSBuild task to build VB6

UPDATE: 01 Feb 2010 — This task is now available in the MSBuild Extension Pack

This is not something I thought I would write, but it seems that there are still many out there who have VB6 in their code base and need to have that code built as part of their build process. There are a few ways to do this, but the easiest would be to simply call a MSBuild task. I’ve therefore added a BuildVB6 task to the FreeToDev.MSBuild.Tasks.dll. Download the update with samples from here.

Parameters

  • Projects [Required]: A collection of paths to the VB6 projects. The OutDir is optional and will default to what is set in the .vbp
  • VB6Path [Optional]: Defaults to C:\Program Files\Microsoft Visual Studio\VB98\VB6.exe

Sample

<Project DefaultTargets="Execute" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="FreeToDev.MSBuildTasks.tasks"/>
<ItemGroup>
     <ProjectsToBuild Include="C:\MyVB6Project.vbp">
          <OutDir>c:\bob</OutDir>
     </ProjectsToBuild>
     <ProjectsToBuild Include="C:\MyVB6Project2.vbp"/>
</ItemGroup>
<Target Name="Execute">
     <BuildVB6 Projects="@(ProjectsToBuild)"/>
</Target>
</Project>

NOTE: If you have used the Detokenise task, this release introduces an updated tasks file.

About these ads
This entry was posted in MSBuild. Bookmark the permalink.

7 Responses to MSBuild task to build VB6

  1. Adrian says:

    Nice to see that I\’m not the only one who associates "Bob (the builder)" with VB project builders… I kept meaning to do this sort of thing, but I always fall back on my custom VB6 build application, which I revisit and enhance once in a while when some VB6 rears its head. Right now it\’s capable of… * Building project groups from .vbg files. * Working out dependency groups (as long as you don\’t have circular dependancies, which you shouldn\’t anyway). * It unregisters old targets before compiling so you don\’t get left with lots of old TypeLib references when you break compatibility.And its piece de resistance – it can rebuild broken dependancies where you\’ve compiled with binary compatibility off (as long as they are in the same build group). This last feature is not something I\’ve seen in the NAnt <vb6> task, or anywhere else. Which is great for making clean TypeLibs (old TypeLibs in VB6 tend to accumulate interfaces in large numbers), where you\’ve broken compatibility and need a fresh build without the pain of building each part. It\’s not quite bright enough to determine whether it should rebuild something based on whether the source has changed, or a dependency has changed (or had it\’s BC broken), but the base code to achieve that is there, I\’ve just never really cared about that too much.It\’s not pretty, it\’s a kludgy VB6 forms app and not really suitable for including in a "real" build process, but it still knocks spots off anything else for VB trees with horrible dependencies (which in my experience, is pretty much anything :-( )If there\’s a use for those features, maybe we could discuss how they were implemented.

  2. Mike says:

    Hi AdrianAt the moment I don\’t have any time to devote to VB6. If you like I will send you the code for the task and you can see if it is of any use.RegardsFTD

  3. Dawid says:

    Hi,I\’m busy looking at writing a similar task to compile Delphi 6 projects. Can I please have a look at your source for the VB task? Thanks,D

  4. Bertrand says:

    Hi,
     
    We got the task from codeplex but the BuildVB6 task is not found
     
    We do an import of FreeToDev.MSBuild.tasks (the name is no longer FreeToDev.MSBuildTasks.tasks)
     
    Any ideas

  5. Mike says:

    Hi Bertrand
     
    The syntax for the task is slightly different if using the suite task. I have noticed that the sample isnt correct in the help file. The sample below should give you an idea of how to call it. Look out for a refreshed beta on Monday. (Sample in next comment due to live space limitation)
     

     

  6. Mike says:

    <Project ToolsVersion="3.5" DefaultTargets="Default" …omitted for brevity
    <ItemGroup>
    <ProjectsToBuild Include="C:\\MyVB6Project.vbp">
    <OutDir>c:\\output</OutDir>
    </ProjectsToBuild>
    <ProjectsToBuild Include="C:\\MyVB6Project2.vbp"/>
    </ItemGroup>
    <Target Name="Default">
    <FTDVB6 TaskAction="Build" Projects="@(ProjectsToBuild)"/>
    </Target>
    </Project>

  7. Bertrand says:

    We are well on our way, thanks for you help.
     
    Bertrand

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s