19

I have a simple Web Setup project that reads from a Deployable Project.

Even though I have set the Setup to DetectNewerInstalledVersion to false I always get that annoying alert box that a previous installation exists and I need to go to the Control Panel and find the software to remove it...

Is there a way to add a script in a new new installation Dialog that could say A previous version was found, press NEXT to uninstall it. ?

balexandre
  • 73,608
  • 45
  • 233
  • 342
  • I found this question and Cosmin Pirvu's answer helpful, but I ran into a problem with the InstallExecuteSequence which is addressed here: [Visual Studio 2010 - RemovePreviousVersions](http://stackoverflow.com/questions/4210294/visual-studio-2010-removepreviousversions) – David McClelland Feb 26 '13 at 20:41

5 Answers5

36

Older versions are uninstalled automatically if you increase your Product Version and change the Package Code. This needs to be done each time you modify the setup project and build a new package.

If you keep the same version and Product Code, older builds cannot be uninstalled automatically. They are detected by Windows Installer before your new package is actually launched. So you need to uninstall them manually.

Cosmin
  • 21,216
  • 5
  • 45
  • 60
  • I can assure that the version is using the Version syntax and it's been updated, example, from `1.0.0050` to `1.0.0051`. `UpgradeCode` as well `ProductCode` are always updated automatically as well. – balexandre Sep 07 '11 at 10:38
  • 3
    UpgradeCode should remain the same, only ProductCode should change. Also, since you are receiving the message you mentioned, you didn't increase the package ProductVersion and change the ProductCode. Where did you make the changes? – Cosmin Sep 07 '11 at 11:21
  • I rectify that, `ProductCode` is the only one that changes. I use the Properties window in the Setup Project. – balexandre Sep 07 '11 at 11:47
  • You need to also increase the ProductVersion. – Cosmin Sep 07 '11 at 12:02
  • 4
    The Assembly version number also needs to change for it to be replaced by the installer. – rageit Jan 17 '14 at 14:26
10

In my case I found out that the setup project wasn't part of the configuration manager. Therefore, it wasn't rebuld on solution rebuilds and setup file with the new version and ProductCode wasn't generated.

The solution is simply to right click on the setup project and click rebuild.

Hope this help to future readers :)

Stephane Rolland
  • 38,876
  • 35
  • 121
  • 169
SimSimY
  • 3,616
  • 2
  • 30
  • 35
2

The answer is not to use the Visual Studio setup project that's already integrated. I'm having the exact same problem: it won't remove previous versions even though I up the version, set it to remove previous version, check for previous version and rebuild, I can install but the files aren't updated. There are some good tools for this out there, check out bitrock, inno setup or wix.

Also Visual Studio 2010 was the last version with setup project support. It's not included in 2012.

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Anders M.
  • 199
  • 2
  • 14
1

I struggled with this for a long time but it is very simple.

  1. Go to manage VS Extensions (VS2019) and install 'Microsoft Visual Studio Installer Project' v0.9.9
  2. Right click on your installer project and go to properties. Keep the UpgradeCode variable in the properties window the same for different versions of the same product.
  3. Change your ProductCode variable between different builds.
  4. Now when you install the product with the same UpgradeCode already on the system, the installer will upgrade your existing product and you will only have one program in the Add/Remove window.
  • I'm sure this is now an easy task, but remember this is a question that is 9 years old and VS2019 was not available, hence mention of VS2010 – balexandre Sep 22 '20 at 18:37
0

Create a .bat file
Write this code:

wmic product where name="SetupProgramName" call uninstall /nointeractive
cd Debug
setup.exe

Put this file in installer directory.

HaibaraAi
  • 197
  • 1
  • 13