Ross
Ross

Reputation: 4578

Visual Studio 2010 Setup Project - Minor update to an existing installation

I have created a WPF app in Visual Studio 2010. I have also created a Setup Project to install this app. The Setup Project handles prerequisites, copies the binaries, populates start menu and desktop, sets up file associations and icons, etc. All this is working great.

I am now working on an updater, which should update my app to a higher minor version (bug fixes, etc). I am using the NetSparkle framework to handle the update process. I've got the process itself working, but I am having issues creating an update MSI file that does what I want.

Here is what I have tried:

  1. I created a second Setup Project, with the purpose of building the "update" MSI file. All it does is copies new binaries. It has a one-screen UI, and obviously does not handle prerequisites, shortcuts, icons, file associations, etc.
  2. I have made sure the UpgradeCode is the same as my main installer Setup Project's UpgradeCode
  3. I have set the Version to be higher than that of my main installer Setup Project

So I build the updater MSI, and plug it into the NetSparkle update process. It seems to work BUT it is creating a second entry for my App in Control Panel Programs and Features (with the higher version number), and it also seems to be resetting the configuration settings for my App - I need those to stay intact! As I said, this is just a minor bug fix update, not a completely new replacement.

What am I doing wrong? Can somebody point me in the right direction? Do I even need an MSI to just update files? (Should I be using a Patch instead? If so, how do I go about creating one?)

UPDATE: I've been playing around with RemovePreviousVersions. If I set it to false, the result is as described above. If I set it to true, then the duplicate entry in Programs and Features is gone, but it also removes all the file associations, icons, start menu and desktops links, etc, which is not what I want. It also breaks the NetSparkle process, in that the app is not automatically relaunched. Really, all I want to do is overwrite the installation files, and that's it, regardless of whether the user is upgrading up one minor version or X minor versions.

Upvotes: 0

Views: 4556

Answers (2)

NathanAW
NathanAW

Reputation: 3367

I'd recommend taking a look at something like WIX to do this. The VS Setup project works for simple stuff, but it's tricky to handle the nuances of MSI installs. With WIX you get fine-grained control over the MSI.

To get started, you can use one of their tools to import your existing MSI, or you can start with one of their templates to get started. I initially started by importing from the VS setup and then copied portions into one of the WIX templates.

Their site has some good info on the upgrade process in their documentation.

Here's a post that talks about the pros and cons of a minor upgrade. And another wix tutorial related to wix.

In my case, I wanted to support minor upgrades too. I use the following in my WIX file to control the upgrade detection logic:

    <!-- 
        This upgrade table will control how and when the installer detect a major upgrade.
    -->
    <Upgrade Id="$(var.UpgradeCode)">
        <UpgradeVersion Minimum="$(var.ProductVersion)" Property="NEWPRODUCTFOUND" OnlyDetect="yes" IncludeMinimum="no" />
        <UpgradeVersion Minimum="1.0.0" Maximum="$(var.ProductVersion)" Property="UPGRADEFOUND" IncludeMinimum="yes" IncludeMaximum="no" />
    </Upgrade>

Upvotes: 3

Cosmin
Cosmin

Reputation: 21436

When setting RemovePreviousVersions to true you are using a major upgrade. So the old version is automatically uninstalled by your new one. If you want to use a major upgrade, your new version should be a complete and standalone installer (it includes prerequisites, shortcuts, icons, file associations, etc.).

What you describe is patching. Visual Studio doesn't support patches, so you will need to create them manually. If you want an easier solution, there are commercial setup authoring tools which offer direct support for both an updater and patches.

Upvotes: 1

Related Questions