Reputation: 1195
I have an app. In-order to install the app I'm using a simple Deployment Project with parameters like this:
DetectNewerInstalledVersion = true
InstallAllUsers = true
ProductCode = GUID (changing with version)
RemovePreviousVersions = true
UpgradeCode = GUID (Allways the same)
Version = 1.0.5 (changing with each deployment).
Problem is, this installer(Deployment Project) never removes previous versions. It installs on top and windows shows that, I have 2 versions of my program(i.e, app which I installed) but none of theme work correctly.
EDIT
I added one line to assemblyInfo: but it still changes nothing. After analyzing my problem more deeply, i realized that installer changes most of the files in Program Files folder, but it removes icon from Desktop and record from registry. After installing on top, i can't even remove application, because i cannot see it in Control Panel -> Programs -> Programs and Features.
If i install on top, i am not able to use program. But if i run it from program files folder it works (newer version). If i install it twice, everything is ok (while installing it second time, wizard asks to repair or remove program).
Maybe this time somebody has something else to suggest?
Solutions for MSI files does not suit me, because final installer is EXE file.
Upvotes: 8
Views: 6622
Reputation: 21
I struggled with this for a long time but it is very simple.
Upvotes: 1
Reputation: 11
I have had the same problem. I worked around it by uninstalling the old version before calling the installer for the new version.
This code will uninstall an installed Product by it's ProductCode:
try
{
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "MsiExec.exe";
p.StartInfo.Arguments = @"/x{53A13817-D52F-4F16-AE27-68D01DA0A656} /passive";
p.Start();
p.WaitForExit();
}
catch
{
MessageBox.Show("Unable to uninstall Application. Manually uninstall/reinstall to update.");
}
Just remember to replace my Product Code with yours. The nice part is that if the product is not installed, it does nothing.
Upvotes: 0