Build Visual Basic 6.0 Applications with Visual Studio Team Services

While giving a webinar on DevOps with Visual Studio Team Services, I was asked if you could build VB6 applications. My response was simple. Visual Studio Team Services can be used to build any language, targeting any platform.  That is true but I wanted to prove it. So in this post I will show you how to build a VB6 application using Visual Studio Team Services. The information here should help you build any language, targeting any platform, with Visual Studio Team Services.

The first thing you will have to do is create a private agent.  Visual Studio Team Services provides hosted build agents running in Azure.  However, VB6 is not installed on those machines.  Therefore, to build VB6 applications you are going to have to create a machine that has VB6 and the Visual Studio Team Services build agent on it.  Whenever I create a build machine I start with a Azure VM using the latest Visual Studio Community template. As of this writing, that was Visual Studio Community 2015 Update 2 with Universal Windows Tools and Azure SDK 2.9 on Windows Server 2012 R2.

Once the machine is provisioned and running in Azure RDP to the machine so we can start installing VB6 and the build agent.  Installing VB6 on Windows Server 2012 R2 is an involved process which I will detail now.

  1. image[3]Disable IE Enhanced Security Configuration
  2. Download Visual Basic 6.0 Enterprise ISO from your MSDN subscription
  3. Download Visual Basic SP6 from here
  4. Right-click the ISO
  5. Select Mount
  6. Right-click setup.exe from the mounted drive
  7. Select Properties
  8. Click the Compatibility tab
  9. Check the Run this program in compatibility mode for: checkbox
  10. Select Windows XP (Service Pack 3)
  11. Click Apply
  12. Click OK
  13. Right-click on setup.exe
  14. Select Run as administrator
  15. imageClick Run the program without getting help
  16. Click Next
  17. Select I accept the agreement
  18. Click Next
  19. Enter your product ID (download from MSDN)
  20. Click Next
  21. Click Next
  22. Click Run the program without getting help
  23. Click Continue
  24. Click OK
  25. Click Custom
  26. Uncheck Microsoft Visual SourceSafe 6.0
  27. Click Continue

This is where things get interesting.  This installation will eventually hang updating the system.

image

Once you reach this point, kill the installation and restart your machine. Once your machine restarts:

  1. Right-click the ISO and select Mount
  2. Right-click on setup.exe
  3. Select Run as administrator
  4. Click Run the program without getting help
  5. Click Next
  6. Select I accept the agreement
  7. Click Next
  8. Enter your product ID (download from MSDN)
  9. Click Next
  10. Click Next
  11. Click Run the program without getting help
  12. Click Continue
  13. Click OK
  14. Click Custom
  15. Uncheck Microsoft Visual SourceSafe 6.0
  16. Select Data Access
  17. Click Change Options
  18. Uncheck everything except Data Environment
  19. Click OK
  20. Click Continue
    This time the installation should complete as expected.
  21. Click Restart Windows

Now we need to install Service Pack 6.

  1. imageRight-click on vb6sp6b.exe
  2. Select Properties
  3. Click Unblock
  4. Click OK
  5. Right-click on vb6sp6b.exe
  6. Select Run as administrator
  7. Enter C:\Users\{user}\Downloads\temp
  8. Click OK
  9. Click Yes
  10. Right-click setupsp6.exe from the C:\Users\{user}\Downloads\temp folder
  11. Select Properties
  12. Click the Compatibility tab
  13. Check the Run this program in compatibility mode for: checkbox
  14. Select Windows XP (Service Pack 3)
  15. Click Apply
  16. Click OK
  17. Right-click on setupsp6.exe
  18. Select Run as administrator
  19. Click Continue
  20. Click I Agree
    The installation should complete as expected.

The final step for VB6 is to make sure the installation folder is in the path and VB6 is registered as a capability.

  1. Open Windows Explorer
  2. Right-click the PC node
  3. Select Properties
  4. Click the Advanced system settings link
  5. Click the Environment Variables button
  6. Double-click Path  in the System variables list
  7. Append ;C:\Program Files (x86)\Microsoft Visual Studio\VB98
  8. Click OK
  9. Click New…
    Field Value
    Variable name VB6
    Variable value C:\Program Files (x86)\Microsoft Visual Studio\VB98
  10. Click OK
  11. Click OK
  12. Click OK

To test our installation we will create a “Hello World” program.

  1. Press the Windows key
  2. Type CMD
  3. Press Enter
  4. Type vb6
  5. Press Enter
    If Visual Basic does not start, repeat the setup to add the installation folder to the path and restart the command window.
  6. Select Standard EXE
  7. Click Open
  8. Change form caption to Hello World!
  9. From File menu, select Save Project
  10. Create a folder and save your project
  11. Close Visual Basic

We need to check this project into Visual Studio Team Services.  I am going to explain how to use Team Foundation Source Control.  If you prefer, you can use Git.  I am just assuming if you are using VB6 you might not have made the move to Git just yet.

  1. Log into Visual Studio Team Services
  2. Click New
    Field Value
    Project name {anything you like}
    Description {anything you like}
    Process template {anything you like}
    Version Control Team Foundation Version Control
  3. Click Create project
  4. Click Navigate to project
  5. Click Add Code

With our team project and Team Foundation Version Control repository created, we can add our code to Visual Studio Team Services.

  1. Start Visual Studio 2015
  2. Click Team Explorer tab
  3. Click Manage Connections
  4. Click Connect to Team Project
    image
  5. Select your server, collection, and project
  6. Click Connect
  7. Click Configure your workspace
    image
  8. Click Map & Get
  9. Open Source Control Explorer
  10. Copy your Hello World project into the mapped folder
  11. Click the Add Items to Folder
    image
  12. Select the folder for your project
  13. Click Finish
  14. Right-click the new folder
  15. Select Check In Pending Changes 
    image
  16. Click Check In

With Visual Basic 6.0 Enterprise installed and our project in Visual Studio Team Services, we can now install the build agent.

  1. Return to Visual Studio Team Services
  2. Click the Manage project gear in the upper right-hand corner of the screen
    image
  3. Click your account name
     image
  4. Click Agent queues tab
  5. Click Download agent
  6. Save the file to your Downloads folder
  7. Right-click agent.zip
  8. Select Properties
  9. Ensure the file is unblocked
  10. Click OK

With the zip downloaded, we can use it to stamp out agents.

  1. Right-click agent.zip
  2. Select Extract All
  3. Enter c:\a1
  4. Click Extract

I number my folders because you can have multiple agents installed on a single machine. I tend to install one agent per core.

  1. Press the Windows key
  2. Type CMD
  3. Right-click Command Prompt
  4. Select Run as administrator
  5. Navigate to the folder where you extracted the file contents
  6. Run ConfigureAgent.cmd
    You can either use the default name or have the name match the folder name, which in my case is “a1”
  7. Now enter your Visual Studio Team Services URL (https://{account}.visualstudio.com)
  8. Press Enter
  9. Press Enter
  10. Press Enter
  11. Sign in to your Visual Studio Team Services account

After you log in, the agent will be configured and begin running.  If you return to your Visual Studio Team Services account, you will see your new agent listed.

  1. Select the agent
  2. Click Capabilities
  3. Confirm the VB6 capability was listed
    image

Now to the easy part: creating the build to compile our VB6 application.

  1. Click the Build hubimage_thumb4
  2. Click the green plus 
  3. Select the Empty template
  4. Click Next
  5. Select your repository
  6. Check the box for Continuous integration
  7. Select Default agent queue
  8. Click Create

With the build created, we need to add the required tasks.

  1. Click Add build step…
  2. Select the Utility category
  3. Click Add next to the Command Line task
  4. Click Add next to the PowerShell task
  5. Click Add next to the Copy and Publish Build Artifacts
  6. Click Close 
  7. Select the Command Line task 
    Field Value
    Tool vb6
    Arguments /m /out errors.txt {project}.vbp
    Working folder [Browse to folder with {project}.vbp]
    Fail on Standard Error [Checked]

    You must use /out or a dialog will be display on any error and your build will hang.
  8. Select the PowerShell task
    Field Value
    Type Inline Script
    Inline Script
    if(Test-Path .\errors.txt)
    {
       $file = Get-Content .\errors.txt 
       Remove-Item .\errors.txt
    
       if($file | Select-String "succeeded." -quiet) { exit 0 }
    
       $file | Where-Object {Write-Host "##vso[task.logissue type=error]$_"}
    }
  9. Select the Copy and Publish Build Artifacts task
    Field Value
    Contents *.exe
    Artifact Name drop
    Artifact Type Server
  10. Click Repository tab
  11. Update Mappings to project folder
  12. Delete cloaked entry
  13. Click Trigger tab
  14. Update Filters to project folder
  15. Click General tab
  16. Click Add Demand
    Field Value
    Name VB6
    Type exists

    This makes sure that only the agent that has Visual Basic 6.0 installed is selected to run this build.
  17. Click Save
  18. Name build
  19. Click OK
  20. Click Queue build…
  21. Click OK

Once the build is done you can browse the artifact to see the exe produced by the build.

image

You can use this technique to build any language using Visual Studio Team Services.

Pingbacks and trackbacks (2)+

Add comment

Loading