# VS2008 Setup program issue



## Kreij (Jul 28, 2009)

I've been beating on this for awhile and I am getting nowhere.

I have a project in VS2008 and a deployment project for it in a single solution.
The problem I am having is that after I recompile both projects, I want the setup program to remove the previous version installed on a users machine and then install the new version.

In the application, I bump the AssemblyVersion and AssemblyFileVersion in AssemblyInfo.cs
(ie:  1.5.0.0  ->  1.6.0.0)

In the setup project properties;
DetectNewerInstalledVersion = True
RemovePreviousVersion = True
I generate a new ProductCode GUID

I compile both without error. When I try to run the setup.exe to re-install on the target machine, it tells me that a newer version already exists on the target machine. 

What am I missing here. It's probably something stupidly simple, but I can't seem to hit the right combination of things to get it to work.


----------



## FordGT90Concept (Jul 29, 2009)

I think the ProductCode has to be the same.  At least I know one of the GUIDs should never change.


----------



## Kreij (Jul 29, 2009)

According to the MS documentation, the ProductCode _must_ be different and the UpgradeCode _must_ remain the same. Seems backwards from a naming convention, but that is how the documentation reads.


> The installer checks UpgradeCode and ProductCode properties to determine whether the earlier version should be removed. The UpgradeCode must be the same for both versions; the ProductCode must be different.



Microsoft Documentation


----------



## FordGT90Concept (Jul 29, 2009)

If they say it it must be true--they made it after all. 

Another idea:
DetectNewerInstalledVersion = False

http://msdn.microsoft.com/en-us/library/yys0tfd0(VS.80).aspx

If it is set to true, it will stop the install if a newer version is detected.  That seems to be what is stopping your install but I doubt it is causing the problem.


Did you triple check all the version numbers?  I'm not sure which version number it checks but make sure the binary version numbers are changed as well as the Installer version number.  The Installer version number is accessed by highlighting the installer project and then looking at the properties toolbar.  It should be at the bottom of the list if sorted alphabetically.

Additionally, I'd recommend making the Installer version and all file versions the same.  It helps it to decide which files need updating and which don't.



RemovePreviousVersion = False?

I'd imagine it would be hard to upgrade an application if it must be removed first.


----------



## Kreij (Jul 29, 2009)

Okay I got it working !!  

Here is what I did ...
Increment AssemblyVersion in AssemblyInfo.cs
Increment AssemblyFileVersion in AssemblyInfo.cs
DetectNewerInstalledVersion = True
RemovePreviousVersion = True
Increment Deployment Project (DP) Version in properties.
Create new ProductCode (automatically asks you this when you change DP Version).

What threw me was updating the installer (DP) Version. Since I was only updating the application project and not the DP, I would not think you would have to update its version. Still seems like a strange way to do things all around.

But anyway, Thanks Ford 

In case anyone wants to know how to access the application's version via code, here is a little tidbit ... This code adds the version to the existing text on the title bar of the application, but you can put this in any appropriate method.


```
[color="Blue"]using[/color] System;
[color="Blue"]using[/color] System.Reflection;

[color="Blue"]public[/color] Form1
{
    InitializeComponent();

    [color="Teal"]Assembly[/color] _Assembly = [color="Teal"]Assembly[/color].GetEntryAssembly();
    [color="Teal"]AssemblyName[/color] _AssemblyName = _Assembly.GetName();
    [color="Teal"]Version[/color] _Version = _AssemblyName.GetVersion;

    [color="Blue"]this[/color].Text += [color="Red"]"   Version : "[/color] + _Version;
}
```


----------

