How do I persuade a VS2005 msi to upgrade?

三世轮回 提交于 2019-12-03 03:28:20

There are several things that need to be done to get "upgrades" to work with MSI's if you want to automatically remove the previous version.

First some background information about the mysterious "codes". There are 3 codes (GUID's) associated with an MSI:

  1. Package Code - This identifies a particular version of the MSI installer and should never be reused across builds. It must always be updated.
  2. Product Code - This identifier is used to ID a particular version of the application. It is up to the installer author to decide when to assign a new product code.
  3. Upgrade Code - This identifies the application and should not change through it's lifetime

The Upgrade Code should never change. For you upgrade scenerio, the Product Code must be changed for each version. Additionally, as you mentioned, you must bump the version number. The Product Code and Upgrade Code can be found by selecting your setup project and going to the Properties Window. The Package Code is hidden in Studio and will always be updated.

The item you are probably missing, is that you also need to set the RemovePreviousVersions setting in the Properties Window to true.

One more thing in addition to mohlsen's answer (For Visual Studio 2008):

In order for your Primary Output (your EXE!) to upgrade properly, you must increment the FILE VERSION

This setting can be found in the Project Properties: Application Tab -> Assembly Information

An easier way to manage this is to REMOVE the AssemblyFileVersion from all assemblies, including the main executable and all the managed DLLs.

In each of your AssemblyInfo.cs files, I recommend doing something like this if you don't care about the version numbers, but want to have some traceability.

[assembly: AssemblyVersion("1.1.*")]
// don't need this [assembly: AssemblyFileVersion("1.0.0.0")]

Everything still compiles fine, and if you don't have the AssemblyFileVersion defined, then the installer assumes that everything is different every time (which is probably fine if you are installing all of the DLLs next to the main EXE).

I spent a long time figuring this out, especially if I don't want to have to increment anything manually!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!