Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
622 views
in Technique[技术] by (71.8m points)

windows installer - visual studio setup project : update doesn't work

I am facing a problem for several days and after many research I couldn't find anything that fit with my case.

Here's the thing : I'm working with Visual Studio 2010 on a solution that contains several projects and a Setup Project. I want the setup project to create a MSI file to update the product from version 1.5 to version 1.6.

I followed this tutorial http://www.simple-talk.com/dotnet/visual-studio/updates-to-setup-projects/ and updated also the assembly version and file version numbers of each project of the solution.

The settings of my Setup Project are :
DetectNewerInstalledVersion : True
InstallAllUsers : True
RemovePreviousVersions : True
Version : 1.6.3
The ProductCode is different from the ProductCode of the previous version
and UpgradeCode is the same than the UpgradeCode of the previous version.

I read that normally the MSI should remove the files which version is newer than the existing ones and replace with the new ones. And when I run the previous MSI (those which updates the product from 1.4 to 1.5) it works just fine as described. (I'm not sure with which version of visual studio it was compiled but I guess it's with VS2008).

Now when I run my MSI, it seems that it first runs the "installation sequence" that replace the old .exe with the new ones, and then it runs the "uninstall sequence" that erase the .exe. And when the install is "finished" there is no more .exe in my application directory. (However in the "Add/Remove Programs" Panel the product apppears as installed in version 1.6).

(NB : I can notice when the "install" part or "uninstall" part of the MSI is running because both have Custom Actions that open a Console Application in which I can have a trace).

After more research I compared the old MSI with mine whith ORCA and I noticed differences in the table InstallExecuteSequence :
With the old MSI, the sequence number of RemoveExistingProducts is 1525 that is between InstallInitialize (1500) and AllocateRegistrySpace (1550).
With my MSI, the sequence number of RemoveExistingProducts is 6550 that is between InstallExecute (6500) and InstallFinalize (6600).
I can't see any other differencies in the table.

I even tried to edit manually with ORCA the MSI and put the sequence number of RemoveExistingProduct to 1525. At the execution the "uninstall part" ran correctly but then I got a 2356 Error (after a few research I guess this is because editing manually the MSI corrupted it).

If anyone have an idea that explains the behaviour of my MSI and how to fix it?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This appears to be a bug with the plugin "Microsoft Visual Studio 2017 Installer Projects". The msi file gets built with an incorrect sequence number (too high). The uninstall of older products happens after the install of new files, so new files get incorrectly deleted.

Manual fix: Change the sequence so that uninstall of old products happens before the install of new items.

  • open the msi with orca.exe (or whatever editor works for you)
  • go to the InstallExecuteSequence table
  • change the RemoveExistingProducts sequence number so that it is between InstallValidate and InstallInitialize. For example, I changed it from 6550 to 1450.

I ended up creating a simple script to do this fix automatically as a post build step. You can get on github it here... InstallerStuff


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...