none
How to add Uninstall as part of the VSTO Setup project.

    Question

  • Hi,

    I have build an application level Excel Addin for Office 2007 using VS 2008 and VSTO 3.0.

    And it is working perfectly fine when i install it using an MSI. But the only problem is, if a previous version of Addin is already installed, then it just throws up an Error message saying that a previous version is installed and i need to go and uninstall the previous version before i install the new version. I wanted to automate this process of unistalling the previous version, so that it gives an option of choosing to uninstall and then upon selecting yes, it directly uninstall's the previous version and install the new version.

     

    Can someone please suggest me on how to go about this.

     

    Thanks,

    Shailendra

    Thursday, October 27, 2011 4:07 PM

Answers

All replies

  • Hi Shailendra,

     

    Thanks for posting in the MSDN Forum.

     

    According to you description, you create a MSI to deploy your add-in is it right?

     

    My solution is that create a batch file to handle it. In the batch file we use msiexec.exe uninstall the produce first. If the produce doesn’t exist it will prompt an alert to notice you. It’s doesn’t affect the result, so please omit this. And then we launch the setup file.

     

    This is my sample:

    @ECHO OFF msiexec.exe /x {[my produce id:********-****-****-****-************]} setup.exe

     

    I hope it can help you.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 31, 2011 10:02 AM
    Moderator
  • Hi Tom .. thanks for the reply ... but could you also please point me any article which will tell me on how too add the batch file to my install. Should this batch file be part of my install or outside of my install and then the user will need to click on this batch file instead of on the MSI file.

    I would assume that i should be creating a batch file with following steps.

    1. check for existing install file. If present trigger uninstall (can you please point me on how to do this)

    2. trigger install

    Please let me know if i am thinking correctly here.

     

    Thanks,

    Shailendra


    Monday, November 07, 2011 6:44 PM
  • Hi Shailendra,

    I tink there no reference for you. And in my aim, this batch file is an individual file. this file must be ran first. If you put the batch file into the msi project it will lost its function, I mean that msi will check producet id before your batch file run and we will can't remove the producet first.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 08, 2011 10:06 AM
    Moderator
  • Hi Shailendra_G,

    Why don't you set the RemovePreviousVersions property of your Visual Studio setup project to true (and also change the Version and ProductCode properties of the new project while keeping the UpgradeCode intact)?

    Also take a look here:
    http://www.developingfor.net/setup-and-deployment/uninstalling-a-previous-version-from-an-msi.html

    Marcel

    Tuesday, November 08, 2011 2:14 PM
  • Thanks Marcel for your reply.

    I have set all the options discussed in the link. Following are the values that i set for the properties in setup project.

     

    Old Install:

    DetectNewerInstalledVersion : True

    InstallAllUsers : False

    ProductCode : XYZ

    RemovePreviousVersions : True

    UpgradeCode : ABC

    Version : 1.1.50

     

    New Install:

    DetectNewerInstalledVersion : True

    InstallAllUsers : False

    ProductCode : KLM

    RemovePreviousVersions : True

    UpgradeCode : ABC

    Version : 2.1.50

     

    But when i try to install the newer version on top of old version, it does not prompt me with any message. It just installs the newer version, but when i launch the application i still see the older version which means the dll's in the GAC are not changing.

    After some more analysis i found that, registry is getting updated and the files in the program files folder have changed to the new version. So the only thing remaining is the dll's which i am putting in GAC. These are not getting overwritten.

    Can you please tell me what am i missing here.

    Thanks,

    Shailendra


    Tuesday, November 08, 2011 5:22 PM
  • Hi Shailendra,

    Please increment the assembly version number of the new class library that you install to the GAC (e.g. to 1.0.0.1) and try once more.

    This is a somehow complicated problem whith multiple timing issues. Read the whole story here:
    http://support.microsoft.com/kb/905238/en-us

    Marcel

    Tuesday, November 08, 2011 6:03 PM
  • yes .. i was just about to post that once i incremented the version numbers, it was successful.

    Now one last thing would be to prompt the user with a message and giving him a choice of upgrading or not. Currently, it just overwrites the previous version without any prompts.

    Any ideas pls.

    Thanks,

    Shailendra

    Tuesday, November 08, 2011 6:09 PM
  • I'm glad that the uninstall worked. That's how it is designed to work.

    As for the user prompt, that's a whole other story. RemovePreviousVersions by itself does not come with an UI. So AFAIK there's no way to simply switch an UI on. And since the Visual Studio setup project has no means of creating a multi-featured setup, I can't see for a way to do what you want from inside the Visual Studio setup project, since this would imply a conditional use of RemoveExistingProducts.

    Of course, you could use Orca or InstEdit or any other tool that edits MSIs to change the execution sequence of RemoveExistingProducts so that you can precede the uninstall with an UI, but - as I already said - you can't do this from inside Visual Studio at this time.

    You could author a bootstrapper application that provides the UI and depending on the user's choosing executes one of two separate MSIs (one containing RemovePreviousVersions and one without it), or you could use a professional tool like AdvancedInstaller, InstallShields etc. that provides you with more control.

    Marcel

    Tuesday, November 08, 2011 6:53 PM
  • ? I am having the same problem about uninstalling previous versions of my service.msi I tried setting "RemovePreviousVersion" property to TRUE and changing Version numbers when i build my setup project. But when i try to run new version service.msi, it gives error as "Specified service already exists." can u plz help me in this ?
    Wednesday, March 14, 2012 7:08 AM
  • Some quick questions to you:

    1. Are you able to manually uninstall your old application/service?
    2. Do the two packages share the same ProductCode?
    3. Do the two packages have the same UpgradeCode?
    4. Have you changed the file versions of your assemblies?
    5. Do the two packages get installed in the same user context (e.g. same value for ALLUSERS)?


    ALLUSERS property:
    http://msdn.microsoft.com/en-us/library/aa367559(VS.85).aspx

    MSIINSTALLPERUSER property:
    http://msdn.microsoft.com/en-us/library/dd408007(v=vs.85).aspx

    Using an UpgradeCode:
    http://msdn.microsoft.com/en-us/library/aa372399(VS.85).aspx


    Marcel

    Wednesday, March 14, 2012 6:05 PM