问题
I create a setup project and installed in a windows system. Before going to install setup project I made setting as
DetectNewInstallerVersion = true
and
RemovePreviousVersion = True
I have also changed the version every time. But If I rebuild the setup project then again install the msi file it will not overwrite the existing file also it will create a new application in program features. I want to uninstall the previous version and install new version without uninstall manually.
回答1:
After several trials and attempts, even by reading the replies of this community, I try to give you a more complete answer than I have found.
1) Right click on your solution project, then Properties. In the Application menù keep in mind the version of the Framework (the setup must have the same version) and then click Assembly Information. In here, write your custom version (Assembly Version and File Version should be identical) using the first three blocks (because the setup property doesn't have the fourth block), for example 1.0.0.
2) In the Explore Solutions panel enter inside the treeview of your setup project in the Detected Dependencies folder, then double click in Microsoft .NET Framework and set
Version = .NET Framework (X.X.X)
where X.X.X is the version number of the Framework used in the solution project.
3) Right click on your project solution, then Properties. Set:
DetectNewerInstalledVersion = True
RemovePreviousVersions = True
Version = //the number used in the assembly at the point 1)
It will appear the message It is recommended that the ProductCode be changed if you change the versione. Do you want to do this? Click Yes.
4) Right click on your project solution, then Recompile. If the Output panel doesn't reports any errors, you can go in the debug folder (usually C:\Users\YOURPCNAME\Documents\Visual Studio 2017\Projects\YOURPROJECTNAME\YOURPROJECTNAME\bin\Debug) and use the .msi or the .exe files to install your project.
When you need to change the version number, run the four points above again. I use this mode for my projects and with .msi file has always worked.
回答2:
In combination with what Wiccio has posted, I also found that setting the property InstallAllUsers to true
InstallAllUsers = True
来源:https://stackoverflow.com/questions/39247420/uninstall-previous-version-installed-new-version-of-setup-project