0
votes

We have a C# ASP.NET 3.5 project with VS 2008.

We also have a VB6 DLL that we call via Interop (yuck...I know).

We use a Web Deployment project with MsBuild and run a batch file to build the project on a build machine.

My question is:

Is there a way to modify the MSBuild project to have the VB6 DLL and interop files created and moved to the proper folders as a part of the build process?

Currently we have to manually build the VB6 DLL and interop file and move them to the appropriate folders first then run the MSBuild batch file.

Any ideas?

4

4 Answers

1
votes

Use MSBuild Exec task to call the VB6.exe Dev project with the /make switch. Then use the MSBUILD copy Task to copy the known output to the location that you want it.

1
votes

You can build the VB6 DLL from the command-line, if you can insert commands into the MSBuild batch file somehow. Just run the VB6 IDE (VB6.exe) with the command-line switch /make and pass the path to the VBP project file. Run VB6.exe with /? if you want to see a list of the other command-line switches.

I'm not sure how to automate the creation of the interop file, but a quick Google search suggests Tlbimp might be worth a try.

I will leave the commands to copy the output to the required directory as an exercise for the reader;)

0
votes

Alternativly, you could look at an automated build tool such as FinalBuilder which you can script easily via a gui to do anything you like including what you ask above. link text

0
votes

http://msbuildextensionpack.codeplex.com/

Has a vb6 build task. HOWEVER, this is just a fancy wrapper for vb6.exe /make.

Aka, the msbuild task helps build a command line like this:

C:\Program Files\Microsoft Visual Studio\VB98\VB6.exe /MAKE /OUT "..\MyProjectFolder\MyOldSchoolVB6Project.vbp.log" "..\MyProjectFolder\MyOldSchoolVB6Project.vbp" /outdir" "..\MyProjectBuildResults\bin"

You don't need the msbuildextensionpack task necessarily, but I find it better to use in the long run. (Your other option is to wire up an exec task and "hard call" the command line above.

THERE IS NO WAY TO BUILD a .vbp without VB6.EXE. Accept this fact and your world will make a little more sense.

I would suggest putting the absolute least common denominator vb6 installation on the build machine (aka, UNCHECK every option possible).

Then code up your .msbuild file.

Something like this:

( I do not define SourceFilesBaseDirectory or OutputBuildDirectory, fyi)

  <PropertyGroup>
    <!-- This allows a way to provide a few options for the library  -->
    <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
    <TPath Condition="Exists('$(ProgramFiles)\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks')">$(ProgramFiles)\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks</TPath>
  </PropertyGroup>

  <Import Project="$(TPath)"/>  


    <ItemGroup>
    <ProjectsToBuildIT001 Include="$(SourceFilesBaseDirectory)\MyProjectFolder\MyOldSchoolVB6Project.vbp">
          <OutDir>$(OutputBuildDirectory)</OutDir>
    </ProjectsToBuildIT001>
  </ItemGroup>


    <Target Name="BuildTheVBProjects001" >

        <MSBuild.ExtensionPack.VisualStudio.VB6 TaskAction="Build" Projects="@(ProjectsToBuildIT001)"/>             

    </Target>

I personally do not like the vb6.exe on my primary build machine. But that's me.

Thank goodness .Net 2.0 and later came up with a way to build the code that did not rely on the IDE being installed.

The "hard call" looks something like this. You will be tempted to short-cut it and try it, it will probably work. But the task above is alot cleaner I believe.

<exec program="c:\myfolder\myexe.exe" failonerror="false">
<arg value="/MAKE" />
</exec>

This is just an example of course, it takes some tinkering to get it right.

But at the end of the day, vb6.exe has to exist on the build box ~~somewhere.

..