Small guide to using VB6 with TFS 2012

I’ve been recently working for a client with lots of VB6 projects. The fun part is that we wanted to migrate from VSS to TFS 2012. Although VB6 no longer supported by Microsoft, there is no reason why TFS would not work for VB6, you can host Java in TFS right? If you have VB6 projects and want to plug them into TFS and have them built in a continuous integration perspective, then I hope this small guide will be helping you.

What to install

First, check you have VB6 with SP6, and the mouse wheel fix as well, I won’t spend more time here since you’re already using it.

You’ll need to install the Visual Studio 2012 edition of your choice, with the latest Update (at this time it is Update 2). Then the famous TFS Power Tools, which add nice check-in policies (and more). Finally, you’ll need the MSSCCI Provider for Visual Studio 2012, 32-bit version or 64-bit version.

After installation check: verify that inside VS 2012 => TOOLS => Options => Source Control, the Plug-in Selection value is set as follows:

clip_image002_thumb1

If you still have Visual SourceSafe around

Warning, the MSSCCI provider has rerouted VB6 source control interactions to the Team Foundation Server source controller. To connect back to VSS, you need to perform some registry operations. Fortunately, small utilities will do that for you, by listing all MSSCCI providers available on your machine, and allowing you to choose which one is active. So you’ll be able to switch back and forth easily from VSS to TFS. This one worked for me => SCPSelector.exe.

clip_image004_thumb1

SCPSelector in action

 

Unwanted prettify options for VB6

Visual Studio 2012 *doesn’t know* about VB6, it knows about VB.NET!

When you are merging files, you don’t want VS 2012 to make assumptions regarding your syntax, and even less *modify your VB6 code*. Make sure you uncheck those options in the TOOLS => Options => Text Editor => Basic => VB Specific menu:

image_thumb

How to map the sources

Local workspaces are great, but the MSSCCI provider is not happy with them. You’ll have to use the traditional server workspaces. Well, it’s not a big deal.

Ok, so let’s create server workspaces and map our VB6 sources from TFS. Now, I want to develop with VB6 but when I open the project with VB6, I get asked to add my project to TFS, doh! Actually, I’d want me and my users to open up any VB6 project as smoothly as possible. To achieve that, you have to edit the MSSCCPRJ.SCC files (or create them), they contain the necessary MSSCCI data to connect to the proper source controller. The bad news is that you can’t share those files! They are specific to your login and your workspace so adding them into the source controller is useless! Sad smile

SNAGHTML2ae733_thumb

VbTfsBinding will do the work for you

I wrote a small utility that will generate all those files for you. Copy it at the root of your workspace and it will generate a MSSCCPRJ.SCC file for every .vbp file in your workspace. Now you can just open any VB6 project in your workspace, you should not be annoyed by any configuration message box. 

Here you are with the source code, and the executable (use it at your own risks of course).

So here’s a few tips for using VbTfsBinding:

  • Configure the config file with your TFS Project Collection URL
  • To share the tool, you can include it in your TFS source controller, in a subfolder at the root of your workspace (or branch), and add a .cmd file that changes the current directory and launches “VbTfsBinding.exe /force”
  • The /force flag will overwrite read-only files, in case someone checks-in a MSSCCPRJ.SCC file

Ok, now the basic source control feature of TFS are usable directly from VB6, but I would advise to always check-in from VS 2012. This just allows you to make sure you don’t forget files in your changesets, you can check all your pending changes with a glance, and I feel more secure that way.

Building your VB6 executables

Now the fun part. Our goal is to call VB6 on as many VB6 projects we want to build. The command line is:

Vb6.exe /m Projects.vbg /out Projects.vblog

Where projects.vbg is project group file which contains the list of projects we want to build.

Let’s follow the path of the Lazy. Let’s use a simple MsBuild .proj file to encapsulate the VB6 compilation logic, and rely on the default DefaultTemplate.xaml of TFS do the rest.

First, prepare your VB6 group file and check it next to your projects in the source controller (paths are relative). You can check the compilation with VB6 on your machine.

Then, add the following MsBuild file next to the .proj file, let’s call it Projects.proj:

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <VBPath>C:\Program Files\Microsoft Visual Studio\VB98\VB6.exe</VBPath>
    <VBPath Condition="Exists('C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.exe')">C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.exe</VBPath>
  </PropertyGroup>

  <Target Name="Build">
    <Exec ContinueOnError="True" Command='"$(VBPath)" /m Projects.vbg /out Projects.vblog"'>
      <Output TaskParameter="ExitCode" PropertyName="VBExitCode"/>
    </Exec>

    <Message Text="---- Start VB Output ------------------------------------------------------------" />
    <Exec ContinueOnError="True" Command="type Projects.vblog" />
    <Message Text="---- End of VB Output -----------------------------------------------------------" />
    
    <Error Condition="'$(VBExitCode)' != '0'" Text="Fatal error because of VB exit code." />
    
    <ItemGroup>
      <VBBinaries Include="**\*.exe" />
    </ItemGroup>
    <Copy Condition="'$(OutDir)' != ''" SourceFiles="@(VBBinaries)" DestinationFolder="$(OutDir)" />
  </Target>
 
  <Target Name="Clean">
    <ItemGroup>
      <VBBinaries Include="**\*.exe" />
    </ItemGroup>
    <Delete Files="Projects.vblog" />
    <Delete Files="@(VBBinaries)" />
  </Target>  
</Project>

Now, create a new build definition, based on the Detault Template, make sure you have a Drop folder location, then the process parameters as follows (transposing the .proj file path to yours):

image_thumb1

The nice thing is that this build is actually pretty standard: it is a build workflow that calls MsBuild for compilation, so there is naturally an MsBuild log file in the build Summary:

image_thumb3

You’ll find your VB6 applications in the Drop Folder:

image_thumb4

It’s up to you to set this build as a continuous integration build, or to schedule it, you know, it’s just a TFS build Winking smile 

Do you feel any better than with VSS? Enjoy! Smile

Visual Studio 2012 Express editions feature matrix

Microsoft has released in last September Visual Studio Express 2012 for Windows Desktop (see various blog posts about it here, and here) which allows many development scenarios and fills the gap left by the two other Express editions of VS 2012 out there which are Visual Studio Express 2012 for Web, Visual Studio Express 2012 for Windows 8. Later on, at the //build/ 2012 conference, Visual Studio Express 2012 for Windows Phone was announced and launched (embedded in the Windows Phone 8 SDK).

The official pages about Visual Studio shows a nice edition comparison page for Pro, Premium, Test and Ultimate editions. But what about Express editions ? What are their features and how do they compare ?

Visual Studio 2012 Express editions comparison table

  Visual Studio 2012 Express for Web Visual Studio 2012 Express for Windows Desktop Visual Studio 2012 Express for Windows 8 Visual Studio 2012 Express for Windows Phone
OS Support Windows 7 SP1 (x86 and x64)
Windows 8 (x86 and x64)
Windows Server 2008 R2 SP1 (x64)
Windows Server 2012 (x64)
Windows 7 SP1 (x86 and x64)
Windows 8 (x86 and x64)
Windows Server 2008 R2 SP1 (x64)
Windows Server 2012 (x64)
Windows 8 only Windows 8 (x64) only
Supported architectures 32-bit (x86)
64-bit (x64)
32-bit (x86)
64-bit (x64)
32-bit (x86)
64-bit (x64)
64-bit (x64)
Languages and tools C#, VB.NET, F# with extension package C#, VB.NET, C++, XAML Javascript, C#, VB.NET,C++ C#, VB.NET, XAML, C++
Toolsets SQL Data Tools, Web Developer Tools SQL Data Tools Code Analysis Spell Checker Code Analysis Spell Checker, Windows Phone SDK 8.0, XNA Game Studio 4.0, Advertising SDK for Windows Phone
Target environment restrictions .NET 4.0 and 4.5
Just Install Framework 3.5 in order to target .NET 2.0, 3.0 and 3.5
.NET 4.0 and 4.5
Just Install Framework 3.5 in order to target .NET 2.0, 3.0 and 3.5
Windows App Store only Windows Phone 7.1 and 8
Emulator for Windows Phone 7.1 and 8 (with limitations)
Project types Class libraries, ASP.NET Web Forms, MVC 3 & 4, Dynamic Data, Server controls & AJAX Server controls and extenders, Silverlight applications, libraries & Navigation applications, Test Project C# & VB: Windows Forms Application, WPF Application, Console Application, Class Library, Unit Test Project

C++: Class Library, CLR Console Application, Managed Test Project, Native Unit Test Project, Win32 Console Application, Win32 Project

JavaScript app, Class Library (for Store), Windows Runtime Component (for Store), Test Library (for Store apps) C# & VB.NET : Windows Phone App, Databound App, Class Library, Panorama App, Pivot App, XAML and Direct3D App, XAML and XNA App, HTML5 App, Audio & Tasks Background Agents

XNA (C# & VB.NET ) : Windows Phone Game, Game Library, Content Pipeline & Projects

C++ (Windows Phone) : Direct3D with XAML, Direct3D App (Native), Runtime Component, Empty Dll, Empty Static Library

Additional elements / features All ASP.NET and Web files
Resources, Datasets, Web Services (client and server)

Page Inspector

WCF Configuration Editor

T4 & Custom templates

Framework components support : Windows Forms, WPF, User Controls (WPF and Forms), Resources, Datasets, Web Services (client and server)

Call Hierarchy

T4 & Custom templates

All Windows Store files (XAML, js) , Resources, XSLT

Installed with Blend for Visual Studio 2012

Windows Store Management (STORE menu)

Call Hierarchy

Store Test Kit, Device Window and Format Menu, Device Simulation Dashboard (network, lock screen, reminders)

Installed with Blend for Visual Studio 2012

Call Hierarchy

XML / XSLT features XML editing with dynamic XSD validation and Intellisense
Packaging / Publishing Publish Web Application Wizard
Web Deployment Packaging capabilities
SQL Deployment capabilities
Publish Wizard Windows app packaging, Upload to windows store Deploy to device, Store Test Kit (automated and manual tests to make sure your app has the minimum requirements for Store)
Debugging Debug ASP.NET, Edit & Continue, ASP.NET Development Server, Local IIS, IIS Express Attaching to an external process is enabled Attaching to an external process is enabled.
Run apps on Local Machine, Remote Machine, Simulator
Attaching to an external process is enabled
Common Features and goodness Solutions can contain multiple projects (no previous Express editions constraints)

Object explorer, Tasks lists, Class View, Snippets Manager, Web Services (Add Service References)

Nuget (Library Manager) full support

Help Viewer with local or online content

Import / Export Visual Studio Settings

Performance and code analysis features No Very basic, no analyze menu, no ruleset configuration Code Analysis (Very basic)

Performance Analyzer (rich reporting and comparison, summary, call tree, modules, etc.)

Code Analysis (Very Basic)

Performance Analysis, Windows Phone App Analysis (Monitoring & Profiling)

Databases SQL Server data tools
Database Explorer
Entity Framework support
SQL Server data tools
Database Explorer
Entity Framework support
No No
UML Features None
Optional features and capabilities Support for F# language by installing F# Tools Windows Azure Development enabled by installation Azure SDK No Comes with Blend for Visual Studio 2012 Comes with Blend for Visual Studio 2012
Extensibility and plugins Extension Manager is there but no support for addins nor extensions
TFS connectivity Yes : Team Explorer for TFS 2012 included
Conditions Requires online registration Requires online registration Requires online registration (works for Blend too)
Requires Windows 8 Developer License
Requires online registration
Windows Phone Developer License for Store publishing
Unit Testing Yes, full support but limited to MsTest (can’t install other frameworks adapters) No
Main constraints summary No C++, no attach to process, no Console or Windows Native projects, No Forms nor XAML, No Call Hierarchy Window No T4 support No Windows Phone 8 Emulator on other systems than Windows 8 x64 at least Pro with SLAT enabled (can’t use VirtualBox nor VMWare)

No T4 support

 

Disclaimer : I’ve been very careful filling this table, it is the result of my very own experience which each edition. This comparison is not official and subject to change with updates. Please report to me any inconsistency.

Visual Studio 2012 makes life much easier for Code Analysis

It may look like it is a small detail, but for me it makes a big change: you can now launch Code Analysis at Solution level!

image_thumb1_thumb

That means only *one* Code Analysis action before checking-in, instead of having to remember which projects have been touched in your solution and launch the analysis separately for each project (as we did VS 2010)!

I’ll take the occasion to talk a bit about Code Analysis configuration.

Per project rule sets

First let me remind that rule sets are configurable in the project properties of each project, and can vary by configuration (Debug, Release, etc.).

image_thumb_thumb

I won’t advise here how to organize *your* rules here, whether it is best or not to have different rule sets for your projects or one rule set “to rule them all” (sorry, couldn’t help). It just depends on what works best for you and your teams. Here’s just an example of what can be done:

SNAGHTML7e84ba9_thumb_thumb

Sharing rule sets

You can easily make the project point to a rule set file stored on a network share. This is something you really want if you have many projects and solutions in your company.

Another great way to share rule sets is the source controller itself, the path to the rule set is stored in a relative form in the project file:

<CodeAnalysisRuleSet>..\..\Rules\MyCompanyCore.ruleset</CodeAnalysisRuleSet>

If you have custom house rules, you can ship them along with your rule sets files. You’ll have to edit the rule set file and add the following Xml node:

<RuleHintPaths>
  <Path>\\server\Rules\2012\MyCompany.Base.Rules.FxCop.dll</Path>
</RuleHintPaths>

Sharing the rules via the source controller (rules are in the project stucutre) works great for isolated projects and distributed contexts. But if you have a big code base you have to place your rule files somewhere at the top of your folder hierarchy, or add a mapping entry in all your workspaces. Moreover, it seems you may have trouble using custom dll rules because the RuleHintPaths are absolute and not relative.

The network approach looks easier, especially with custom rules, but you may encounter nasty load file problems, I’m still trying to solve that kind of problem for one of my clients, some computers would just not manage to execute the rules (I’ll post here when I find the solution).

Code Analysis for the build

The build server will also run Code Analysis, so you have to make sure your rule sets are available to the build process (workspaces, network paths, etc.). Generally, they will. This is the easy part, you have multiple options:

image_thumb2_thumb

  • AsConfigured: will obey what you have set up each project Code Analysis settings (see the Enable Code Analysis on build option in the screenshot above)
  • Always: will force Code Analysis for every project, even if the aforementioned option is not checked
  • Never: will force CA not to run…

It is simple and easy, there is no need to create a new project configuration named “Debug with CA” and check the “Enable Code Analysis on build” option in every project, then configure the build to use this configuration. No, we don’t need to do that! Smile

I’d be curious to know how your share your custom rules in your company, feel free to drop a comment Smile

Error during VS 2012 with update 1 install, just re-install update 1

I’ve just installed Visual Studio 2012 with update 1 (the ISO is available for in MSDN subscribers downloads) on a test TFS 2012 server.

Visual Studio with update 1 install

The install went well, I clicked “LAUNCH” and chose the C# development settings (first launch only dialog), but then an error occurred :

devenv.exe crashed because of an error coming from Microsoft.VisualStudio.Progression.LanguageService.CSharp

After re-launch, Every time I would right-click in my Solution Explorer, Visual Studio would continue crashing :

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.MissingFieldException
Stack: etc.
   at Microsoft.VisualStudio.Progression.LanguageService.CSharp.CSLanSvcProvider.InitializeProvider

I was not the only one, as you may find here, and here, but re-installing only the update 1 did the trick, if it does not for you, you may have to fully re-install Visual Studio.