Windows > Windows Forms Forums > ClickOnce and Setup & Deployment Projects > Creating Setup that removes previous installed components
Ask a questionAsk a question
 

AnswerCreating Setup that removes previous installed components

  • Monday, November 02, 2009 6:02 AMCSharpLeader Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I have written a Setup application for my one of application. Each time I change my application, I have to generate new setup for that. I noticed that I have to uninstall previously installed application otherwise it gives error saying "Another version of this product is installed on your computer etc....". I know that this error comes because I don't change the product ID and/or version number for my application.

    In this case, I want my setup to detect the previously installed components for same product id and version number and rather giving me error, it should uninstalled previous version and should proceed to new installation.

    Is this possible? Is there any other way to get rid of uninstalling previously installed application before installing same?

    Thanks.
    • Moved byChao KuoMSFTWednesday, November 04, 2009 9:16 AM (From:Visual C# General)
    •  

Answers

  • Monday, November 02, 2009 6:09 AMTrecius Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Well, you need to increment your version number for your setup program.  Usually you do this for your application too.

    The next step, you should get the MSI editor called Orca.  Orca will allow you to edit MSIs.  In Orca, go to the InstallExecuteSequence, find the entry "InstallExecute."  Once found, drop the row.  Finally, in the same window, find "RemoveExistingProducts."  Bump that sequence to just after "InstallInitialize."  InstallInitialize is 1500, so make RemoveExistingProducts to 1501 or so.

    Hopefully this helps.


    Trecius
  • Wednesday, November 04, 2009 6:49 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    That's what the RemovePreviousVersions setup project property is for. Set that property, then increment the version of the setup project, accept the OK to change product code, increment the file versions of the files that have been changed, and that should do it.


    Phil Wilson
  • Thursday, November 05, 2009 7:58 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    If you search this forum for installastate you might find other occurrences and solutions.  Is this VS 2005 or 2008? The upgrade behavior is different.
    If you get this during an upgrade it's not clear to me why you don't get it during an uninstall.  Sometimes it's because you haven't populated all the custom action nodes with your installer class custom action. If there's no Install custom action call then the installstate file isn't created, and then it looks for it at uninstall time.
    Phil Wilson
  • Friday, November 06, 2009 6:41 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You may have run into this:
    http://support.microsoft.com/kb/906766 
    Phil Wilson

All Replies

  • Monday, November 02, 2009 6:09 AMTrecius Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Well, you need to increment your version number for your setup program.  Usually you do this for your application too.

    The next step, you should get the MSI editor called Orca.  Orca will allow you to edit MSIs.  In Orca, go to the InstallExecuteSequence, find the entry "InstallExecute."  Once found, drop the row.  Finally, in the same window, find "RemoveExistingProducts."  Bump that sequence to just after "InstallInitialize."  InstallInitialize is 1500, so make RemoveExistingProducts to 1501 or so.

    Hopefully this helps.


    Trecius
  • Monday, November 02, 2009 6:17 AMCSharpLeader Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks. that was helpful answer but I am wondering if we could achieve it without using any third party tool. Is there any such option available in C# Setup building process?

    Thanks.
  • Wednesday, November 04, 2009 6:49 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    That's what the RemovePreviousVersions setup project property is for. Set that property, then increment the version of the setup project, accept the OK to change product code, increment the file versions of the files that have been changed, and that should do it.


    Phil Wilson
  • Thursday, November 05, 2009 4:05 AMCSharpLeader Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Phil, I have tried exactly what you have said and I have incremented MyApplication V1.1 but it says "Could not find a part of the path "C:\Program Files\MyApplication V1.0\MyApplication.Setup.CustomActions.InstallState".

    What could have caused this?

    Thanks.
  • Thursday, November 05, 2009 7:58 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    If you search this forum for installastate you might find other occurrences and solutions.  Is this VS 2005 or 2008? The upgrade behavior is different.
    If you get this during an upgrade it's not clear to me why you don't get it during an uninstall.  Sometimes it's because you haven't populated all the custom action nodes with your installer class custom action. If there's no Install custom action call then the installstate file isn't created, and then it looks for it at uninstall time.
    Phil Wilson
  • Friday, November 06, 2009 4:02 AMCSharpLeader Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am using VS 2005.

    Thanks.
  • Friday, November 06, 2009 4:10 AMCSharpLeader Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    >> Sometimes it's because you haven't populated all the custom action nodes with your installer class custom action.
    I have an Installer.cs and from there, I am doing registration of myapp.dll which I added as a file in Setup. I don't get any error during uninstall. I am getting "Could not find a part of the path "C:\Program Files\MyApplication V1.0\MyApplication.Setup.CustomActions.InstallState" error when I install the new version V1.1. Please note that the error messages is for old version V1.0.

    Thanks.
  • Friday, November 06, 2009 6:41 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You may have run into this:
    http://support.microsoft.com/kb/906766 
    Phil Wilson