Upgrade uses OnCommit Custom Action from previous installer - c#

While upgrading my solution from version 1 to 2 using the new MSI, I noticed one of my custom actions which configure the application was using values which belong to version 1 (on the OnCommit action)
I added messageboxes and logs that print out the assembly version and confirmed that during an upgrade, the windows installer is using the dll from the previous MSI. However, if I manually install the newer MSI the correct custom action is used.
Is there a way to get around this? Have not found much information on why it uses the previous custom action?
I set the RemovePreviousVersions = true and UpgradeCodes are equal while ProductCodes are different.

I believe that this is an old bug:
https://support.microsoft.com/en-us/kb/555184
and there is another support article about it that I can't find. It may have been deleted because it applies to older versions of setup projects. I think the detours are things like renaming the assembly, and changing its assembly version.
The issue (as you might guess) is that the uninstall loads the assembly to do the uninstall, and the assembly from the upgrade install is identical as far as the load rules determine in this situation (reflection loading), so it does not load your new assembly but uses the older one that is already loaded. This all implies that you are using a very old version of Visual Studio setup projects that first uninstall the old product then install the new one. That hasn't been the default behavior since (and including) Visual Studio 2008, so I don't think you'd get the issue with a newer version.

Related

Installer Projects extension Remove Previous Version

I use the Installer Projects extension for visual studio 2015 to distribute my sw written in WPF.
I would like the installer, before the installation, remove all the files in the program folder.
I tried putting true RemovePreviousVersion properties but does not work.
Does anyone know how to fix?
You have to make sure that ALL your project versions inside AssemblyInfo is altered to a new one (greater than the previous one) and also, check that the Installer version it self is altered and a new id is generated (be carefull not to alter the installer id but the upgrade id). It should prompt you when changing the version of the installer that new id will be generated.
Also, because the installer projects are no longer supported directly (see wix), a lot of issues may be raised by the vs extension.
Ypu may also try the Inno setup. It very powerfull and easy to migrate from clasic installer projects.
Good luck.

installing c# setup with same version

I want basic information about windows installer. I made installer that has version 1.0.0.0. I installs this on your pc. Now I add new features to app and build setup(in debug from date I know its updated) and give it to you(its still 1.0.0.0). you uninstall old one and install this one. I have question here, what would be the impact ?
Actually case is that, I gave build 1.0.0 to my friend, he install this. I make UI and some logical changes in Form1(c#), build the setup(its new but still 1.0.0) and give it to him. he uninstall old one and installs this one. when program executed it shows new UI changes but my friend is asking that UI changed but not logic changed. I cant understand as its not logical argument that if UI updated of setup but not logic.
Can someone give valid argument ?
Well, you're going to be hard pressed convincing your friend that he has a new version, given that the product version has not changed. How can you confirm that he actually uninstalled the old version, or even installed the new version (and not have just run the old installer by mistake).
I think you have two options:
Update the product version of the installer, so that you can prove that a new version has been installed. This could just be a minor or revision version change (e.g. 1.0.0.1)
Set the version of the .NET assemblies. If you change these with each build, even if your installer version remains the same, you can verify that he has the new assemblies.

.Net Setup Project/Upgrades and maintaining separate versioned folders

I've seen several articles online where people show how to create windows setup projects, and then subsequently use the same setup project to deploy updates as in: Updates to setup projects. When performing this sort of install though, the previous version is always uninstalled first before the new version is installed. I'm curious if anyone has found a way to create versioned folders to maintain the previous versions that the user has already installed?
Example:
On first run of the setup.msi, it creates the default directory: [ProgramFilesFolder][Manufacturer][ProductName][ProductVersion] -> C:\Program Files\Manufacturer\Product\1.0.0.
On each next update, it creates new directories as in: C:\Program Files\Manufacturer\Product\1.0.2
There are some cases based on certain configurations where for performing certain functions, we would want to use an older version, rather than the latest version. I know this may sound weird, so I'm not going to get into the reason for why. Just curious if anyone thinks this is doable through regular setup projects.
This is called side by side installation and it's not supported by Visual Studio setup project. Basically, you need to modify the upgrade rules to allow two different versions to be installed on the same machine.
However, each version functions independently of other versions. So version 2.0 shouldn't use files from the version 1.0 folder.
If you want to preserve existing files during an upgrade, you can try this approach: https://web.archive.org/web/20130513032659/http://setupanddeployment.com/installer-concepts/preserve-data-install/

Updating the MSI for a Project in Visual Studio 2008

In reference to the post below, where it says I should increase the version number for older versions to be replaced by newer ones.
MSI Installer fails without removing a previous install
What I find is, just changing the version number didn't do the job. I had to change the product code also, which I got an option to change through a Message Box just after changing the Version Number.
Is this how it's supposed to be?
I think Visual Studio setup project uses the version number to generate the Product Code which is why you must update both. The product code is a unique GUID that identifies the installed application. It is good practice to update both each time you release an installer. Otherwise the client will get a message that says something like "Another version of this application is already installed, please uninstall that version first..." etc. and the MSI will not install the new version.
So to remove a previous version before installing a new version you must set RemovePreviousVersions property to True and update the version number and product code.
You can automate the version number and product code part by executing a script in the PreBuildEvent of the setup project. You can find interesting article and sample script on CodeProject http://www.codeproject.com/KB/install/NewSetupVersion.aspx

How do I persuade a VS2005 msi to upgrade?

I have a Windows service written in C# using VS2005.
The installation is via a wizard that calls msiexec to install the msi file also created using VS2005.
I am having trouble generating an msi file that will upgrade from one version of the service to another. The wizard program handles detection of the currently installed version, stopping the service, coming up with an appropriate command-line for msiexec and then re-starting the service.
The existing msi has a version property of 1.1.02, the new one is 1.1.03. The product and upgrade codes are identical.
Uninstalling 1.1.02 manually via add/remove programs works fine, as does installing 1.1.03 onto a "clean" system.
Upgrading 1.1.02 to 1.1.03 goes through the motions but the end result is 1.1.02 installed.
The command line that the wizard uses for upgrading is:
msiexec /qb /i "MyProduct.msi" REINSTALL="ALL" REINSTALLMODE="vos"
Where am I going wrong? I'm assuming I must have missed something fairly fundamental...
The fall-back position is to inform customers that they need to manually uninstall 1.1.02 before running the wizard to install 1.1.03 but I'd rather not have to do that.
Edited to add:
Changing the product code (as VS2005 also prompts you to) actually removes the ability to upgrade at all, as it the installer won't let you do a reinstall if that product code hasn't previously been installed.
All it will then let you do is install (and then you get the usual "service already exists" -type message).
There are several things that need to be done to get "upgrades" to work with MSI's if you want to automatically remove the previous version.
First some background information about the mysterious "codes". There are 3 codes (GUID's) associated with an MSI:
Package Code - This identifies a particular version of the MSI installer and should never be reused across builds. It must always be updated.
Product Code - This identifier is used to ID a particular version of the application. It is up to the installer author to decide when to assign a new product code.
Upgrade Code - This identifies the application and should not change through it's lifetime
The Upgrade Code should never change. For you upgrade scenerio, the Product Code must be changed for each version. Additionally, as you mentioned, you must bump the version number. The Product Code and Upgrade Code can be found by selecting your setup project and going to the Properties Window. The Package Code is hidden in Studio and will always be updated.
The item you are probably missing, is that you also need to set the RemovePreviousVersions setting in the Properties Window to true.
One more thing in addition to mohlsen's answer (For Visual Studio 2008):
In order for your Primary Output (your EXE!) to upgrade properly, you must increment the FILE VERSION
This setting can be found in the Project Properties: Application Tab -> Assembly Information
An easier way to manage this is to REMOVE the AssemblyFileVersion from all assemblies, including the main executable and all the managed DLLs.
In each of your AssemblyInfo.cs files, I recommend doing something like this if you don't care about the version numbers, but want to have some traceability.
[assembly: AssemblyVersion("1.1.*")]
// don't need this [assembly: AssemblyFileVersion("1.0.0.0")]
Everything still compiles fine, and if you don't have the AssemblyFileVersion defined, then the installer assumes that everything is different every time (which is probably fine if you are installing all of the DLLs next to the main EXE).
I spent a long time figuring this out, especially if I don't want to have to increment anything manually!

Categories

Resources