Visual Studio: How to automatically uninstall prev

2020-06-08 13:33发布

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. ?

4条回答
孤傲高冷的网名
2楼-- · 2020-06-08 13:40

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.

查看更多
Evening l夕情丶
3楼-- · 2020-06-08 13:48

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 :)

查看更多
闹够了就滚
4楼-- · 2020-06-08 13:55

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.

查看更多
男人必须洒脱
5楼-- · 2020-06-08 14:02

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.

查看更多
登录 后发表回答