I have created a msi install package for my project from the VS2008 deployment project. but I am having problems when it comes to upgrading installs, The previously installed version does not get overwritten. How do I ensure that previously installed versions get overwritten?
问题:
回答1:
- In Visual Studio select your Setup project within the Solution Explorer
- Open the Properties Window
- don't right click and select properties.
- select View - Properties Window
- set RemovePreviousVersions to true
- increment the version to a higher number
- select yes in the upcoming message box
If you built and deploy this new setup, a setup with an older version number will be deleted.
Important: the setup version number is completely independent from your application or assembly version number!
回答2:
(Oliver's answer is correct, but I wanted to add pictures and some more details)
Select the setup project in your solution, then open the Properties pane (the tab next to Toolbox):
- Make sure
DetectNewerInstalledVersion
is true (it is be default) - Set
InstallAllUsers
to true - Set
RemovePreviousVersions
to true - Update the
Version
number and hit Enter - After you hit enter, Visual Studio will ask if you want to generate a new GUID for
ProductCode
, click yes
Additionally, you need to update the version numbers for each project in your solution, because the installer will only replace DLLs if their version number has been incremented:
- Open each project's AssemblyInfo.cs and update the
AssemblyVersion
andAssemblyFileVersion
numbers
Or a better way:
- Remove
AssemblyVersion
andAssemblyFileVersion
lines from each project's AssemblyInfo.cs - Link to a VersionInfo.cs file in your solution with those 2 lines
- Step-by-step for the above: The Right Way To Version Your Assemblies
Right-click on the setup project and select Properties (a different Properties dialog):
- Set Windows Installer 4.5 as a Prerequisite instead of the Visual Studio default of Windows Installer 3.1
I'm not sure if all of these steps are necessary, and there may be other ways to set this up, but the above steps work for me.
回答3:
Windows Installer has built in checks on your files to make sure that the version is higher than the previous version of that file. If it is not, Windows Installer will not overwrite it. For more extensive info on how Windows Installer handles versioning check out this MSDN article:
http://msdn.microsoft.com/en-us/library/aa368599%28VS.85%29.aspx
回答4:
We need to set REINSTALLMODE property of our msi file to amus.
Following is the link to know more about the meaning of 'amus' http://msdn.microsoft.com/en-us/library/aa371182%28VS.85%29.aspx
There are two ways to do that.
- By using msiexec.exe which comes with .NET SDK (if you have VS 2005 or VS 2008 it will come with it, just browse to command prompt of visual studio and you will find it there)
once you find msiexec.exe just type following command to set REINSTALLMODE property to amus for your installer.
msiexec.exe /i foo.msi REINSTALLMODE=amus