views:

720

answers:

1

At the moment our build automatically updates the version number in the deployment project file (VS2008) and changes the ProductCode and the PackageCode.

We don't use much MSI functionality at all, it's more of a packaging method and a way to run custom actions which do some activity depending upon a definition file which is shipped as content within the MSI.

So, in terms of MSI features all of our builds look the same, they will just be pulling in newer versions of the other projects outputs rather than any changes within the deployment project, and thus we don't change the structure of the MSI at all.

So, am I safe to leave the ProductCode stable?

The reason I would like to do this is that I was uninstalling via product code, until I've just found that this is a silly way given that our build changes them all the time!

Or, is there any way we can uninstall using the UpgradeCode which is a never changed value?

FEEDBACK:

I dug a little more on this one and changed the way that we do an uninstall in our deployment system that deploys into our sizable test estate. Rather than extract the ProductCode out of the MSI and use that in an MSI /X command I now extract the UpgradeCode from the MSI. As part of the uninstall I deliver and remotely execute (via PSEXEC) a small vbs script that finds the related products by

set oWI = CreateObject("WindowsInstaller.Installer")
set related - oWI.RelatedProducts(wscript.arguments(0))  
if related.Count == 1 then
    uninstallString = "msiexec /X " & related.Item(0) & " /qn"
    set oShell = CreateObject("WScript.Shell")
    oShell.Run uninstallString, 1, True
end if

ok, probably not the worlds best vbs - but it works by passing the UpgradeCode as the first parameter into the script. There are some more lines for logging etc so we can tell what happened in the audit trail.

Bit more long winded that just calling msiexec directly through psexec but I was delivering the msi and a settings file already so sending down a little script isn't really an issue.

This may help somebody else - who knows.

+1  A: 

If you open the .vdproj in Visual Studio, select the project in Solution Explorer pane, and then look in the Properties pane, you will find a property named "RemovePreviousVersions". If this property is set to true, any installed products with the same UpgradeCode, but with an earlier version, will be automatically uninstalled when the new version is installed.

Daniel Pratt
The reason I was doing a full uninstall first was because of the changed behaviour in VS2008 in that the uninstall action of the original msi isn't called before the install action of the new msi. Our service creation custom action then falls over, but having dug a bit more on that now.
Alan Mullett