How can tlbimp be used to specify different File and Assembly versions?

In the end we found a couple of links about a project called tlbimp2 on codeplex, and compiled our own modified version of tlbimp2:

  1. http://clrinterop.codeplex.com/discussions/208832
  2. http://clrinterop.codeplex.com/SourceControl/changeset/view/39798

I took the code from the tlbimp project of 2. and modified it along the lines of 1. There were a couple of problems we had to work around:

In TlbImp.cs I had explicitly to assemble the file version number from the result of FileVersionInfo.GetVersionInfo, since the FileVersion property was empty:

    if (Options.m_strFileVersion == null)
    {
        // get the fileversion
        var versionInfo = 
            FileVersionInfo.GetVersionInfo(Options.m_strTypeLibName);
        Options.m_strFileVersion = 
            versionInfo.FileMajorPart 
            + "." + versionInfo.FileMinorPart 
            + "." + versionInfo.FileBuildPart 
            + "." + versionInfo.FilePrivatePart;
    }

In tlbimpcode.cs I had to switch:

 AsmBldr.DefineVersionInfoResource(
   strProduct, 
   strProductVersion, 
   strCompany, 
   strCopyright, 
   strTrademark);

to:

 AsmBldr.DefineVersionInfoResource();

Or the custom resources would not be used.

Hope this helps someone else with the same problem.