Search code examples
visual-studio-2015windows-installervdproj

How best do I generate new ComponentIDs in Visual Studio Installer Projects (VS2015)


Scenario:

  • We've got a .vdproj installer (actually we have many, with merge modules, but lets keep this simple).
  • We've got a new release of our product.
  • I changed product code, upgrade code & versions, re-guided AssemblyInfos and any COM interfaces, and changed the default install location.

Everything appeared fine, the programs work Side By Side. However, on Uninstall the program menu and desktop shortcuts aren't removed if both versions are installed at the same time, complaining that they couldn't be removed because the component wasn't removed. (Smells of reference counting eh?).

Although this is a cosmetic issue, I decided to have a look and in Orca I noticed the ComponentIds of files were the same.

It appears these are hashes based on the [TARGETDIR]\myfile, rather than the actual expanded TARGETDIR.

E.g. my TARGETDIR is effectively different on install, c:\program files\myCompany\v1.0\myfile and c:\program files\myCompany\v2.0\myfile

But to the installer project, I think it's based its hash off TARGETDIR\filename.

I have discovered that

  • renaming the output file to myfile2 produces a different ComponentId
  • alternatively - creating a sub folder of TARGETDIR called v2.0 in the install produces a different ComponentId. But I'm not sure what impact that will have.

Have I correctly interpreted what's happening, and is this my only workaround? What are the risks of sharing a top level folder as the TARGETDIR?

Microsoft haven't updated this VS2015 component in over a year, nor Open Sourced it, I'm assuming they're happy for it to die and I should move to Wix?

UPDATE This appears to be only an issue with merge modules, rather than the top level installers.


Solution

  • Visual Studio doesn't expose the component ids, as you've discovered. If there are other issues with component ids (or something WiX supports that VS doesn't)then yes, migrate to WiX. However in your case of perhaps just a single component id then easiest solution is to do a post-build step to change that component id. With Windows Installer SQL and a script such as WiRunSql.vbs (from the Windows SDK) you can just change the id.

    https://msdn.microsoft.com/en-us/library/windows/desktop/aa372021(v=vs.85).aspx

    Microsoft tried to deprecate installer projects once and they were brought back by popular demand, so a plan to migrate to something else might be a good idea in any case.