How do I ensure my winform application deployment overwrites old versions - c#

I have created a msi install package for my project from the VS2008 deployment project. but I am having problems when it comes to upgrading installs, The previously installed version does not get overwritten. How do I ensure that previously installed versions get overwritten?

In Visual Studio select your Setup project within the Solution Explorer
Open the Properties Window
don't right click and select properties.
select View - Properties Window
set RemovePreviousVersions to true
increment the version to a higher number
select yes in the upcoming message box
If you built and deploy this new setup, a setup with an older version number will be deleted.
Important: the setup version number is completely independent from your application or assembly version number!

(Oliver's answer is correct, but I wanted to add pictures and some more details)
Select the setup project in your solution, then open the Properties pane (the tab next to Toolbox):
Make sure DetectNewerInstalledVersion is true (it is be default)
Set InstallAllUsers to true
Set RemovePreviousVersions to true
Update the Version number and hit Enter
After you hit enter, Visual Studio will ask if you want to generate a new GUID for ProductCode, click yes
Additionally, you need to update the version numbers for each project in your solution, because the installer will only replace DLLs if their version number has been incremented:
Open each project's AssemblyInfo.cs and update the AssemblyVersion and AssemblyFileVersion numbers
Or a better way:
Remove AssemblyVersion and AssemblyFileVersion lines from each project's AssemblyInfo.cs
Link to a VersionInfo.cs file in your solution with those 2 lines
Step-by-step for the above: The Right Way To Version Your Assemblies
Right-click on the setup project and select Properties (a different Properties dialog):
Set Windows Installer 4.5 as a Prerequisite instead of the Visual Studio default of Windows Installer 3.1
I'm not sure if all of these steps are necessary, and there may be other ways to set this up, but the above steps work for me.

Windows Installer has built in checks on your files to make sure that the version is higher than the previous version of that file. If it is not, Windows Installer will not overwrite it. For more extensive info on how Windows Installer handles versioning check out this MSDN article:
http://msdn.microsoft.com/en-us/library/aa368599%28VS.85%29.aspx

We need to set REINSTALLMODE property of our msi file to amus.
Following is the link to know more about the meaning of 'amus'
http://msdn.microsoft.com/en-us/library/aa371182%28VS.85%29.aspx
There are two ways to do that.
By using msiexec.exe which comes with .NET SDK (if you have VS 2005 or VS 2008 it will come with it, just browse to command prompt of visual studio and you will find it there)
once you find msiexec.exe just type following command to set REINSTALLMODE property to amus for your installer.
msiexec.exe /i foo.msi REINSTALLMODE=amus

Related

Setup Project not capturing updates

This is my first dabble into Setup Projects.
I have Solution in VS2013.
Within the solution is a C# Winform project, and a Setup Project.
On first build, I can use the setup.exe to install my application on my laptop; no issues.
However, when I make changes to my Winforms, these are not reflected by any subsequent re-install.
Quite simply, the build does not pass winform changes to the setup package.
To explain:
I make changes to a form, for example I add a label or button.
In my setup project I increase the version number.
VS automatically generates a new Product Code.
Build all.
Copy the setup.exe + msi from the setup project's debug folder.
Paste to desktop.
Execute setup.exe
Install completes successfully.
Control Panel > Programs, confirms the new version number.
Yet running the app, none of my form changes are there !?
Hope someone might be able to explain what's going on, what I am missing !?
Many Thanks
A Visual Studio Installer project will automatically pick up the right version of the application if you add the Primary Output of your application. So that's that.
It could be that Visual Studio does package the new version of the executable, but it does not get installed, because you forgot to increase the executable's version number, too (not just the installer's version number!). AFAIK, Windows Installer replaces files only if the version number differs.
What happens when you uninstall the old version before installing the new version? Do you then see your changes? If that's the case, try increasing the version number before the next update.
Change all version numbers of your hosted application in AssemblyInfo.cs together with Version number and Product code in your installer (Setup project).

Visual Studio 2015 Add Publish Version Number

In previous VS versions adding publish version is easy. Just need to go to the project properties -> Publish and specify the publish number as shown in the below figure.
But this is the project properties window from the Visual Studio 2015.
Here I can't find any location to specify the publish version as I did on previous VS versions. So have they dropped this functionality to add publish version numbers or have they moved it to another place??
Try This!
Its free!
https://marketplace.visualstudio.com/items?itemName=PrecisionInfinity.AutomaticVersions
Usage:
To configure Automatic Versions, go to the Tools Menu -> Automatic Versions Settings
Each time you build your project, the versioning will automatically change.
To use the "On Demand" version options, right click on the project and choose "Build New Version"
Hope this helps!
Microsoft deprecated add-ins in Visual Studio 2015 so build number increment add-in is no longer working.
Your possible replacement is VsIncrementer (link)

Latest built installer for a project doesn't show up in Add/Remove Programs

I noticed within the past couple of weeks my latest builds of a specific project are not showing up in Add/Remove programs.
I am using Visual Studio 2010, Windows7 64-bit (though I've also tried this over two Windows 32-bit machines). All latest service packs and updates are installed. The solution is made up of several projects with various references. The Setup and Deployment project is not the Install Shield version, but the one built in Microsoft project.
Previous versions of the software install fine, and still do... But if I pull down a tagged earlier version from CVS, and rebuild the installer for those versions, they do not work either.
I've opened the MSI in Orca, and I can see that the ARPNOREMOVE, ARPSYSTEMCOMPONENT are both set to 1. When the project gets installed, a registry entry SystemComponent Dword value is created. If I remove that registry entry, the application shows up. Based on everything I've read and researched I have found people that WANTED this functionality, but were told that Visual Studio can't do this on its own. Their solutions were to use Orca to add the ARPNOREMOVE or ARPSYSTEMCOMPONENT. At this point, all of the people who I found had my problem either had a basic default installer and they didn't know what name they were looking for in Add/Remove Programs or some other basic error that doesn't apply in my situation.
I've tried all of the following:
-Previous versions of tagged versions on CVS
-Multiple development machines
-Multiple computers to verify none show up in Add/Remove programs
-Resetting all Visual Studio settings
-Building from a clean development environment
-Removing Installer project from the solution and creating a new installer project
The weird part is that if I create a new solution and just create a setup and deployment project within, that installs fine. Can anyone having any idea about this help me out ?
So this is what I found out. We are using National Instruments Measurement Studio for .Net and the legacy controls. When using the legacy controls a certain merge module gets recognized as a dependency. For whatever reason, now this merge module change the behavior of the installer that is compiled. I've contacted National Instruments and am now working with them.
First, yes, you figured out the correct property name. Yes, ARPSYSTEMCOMPONENT is it which leads to an "unvisible" install under Add/Remove programs (ARP for insiders, although the name has changed post XP).
And it is possible to set/change the resulting "SystemComponent" entry in registry later which is not the case for all properties.
ARPNOREMOVE just controls if the uninstall in ARP is really possible to perform.
I have looked into Visual Installer before really, because it is so limited for MSI experts, but after taking a quick look there is a .vdproj (project file) created with VS 2010, and not very surprisingly, all the MSI information is coded there. The visual setup editors you can see in the solution explorer are only a subset.
Just look for "ARP" and you will find some properties set. The meanings of the values are maybe not so easy to guess, but from a rational point of view:
Either there is some setting inside there or a custom action (listed there too) which sets that property!
In my minimal test with the wizard only the ARPCONTACT property was set in the resulting msi file.
At least you could take the .vdproj file cor diffs with other checkedin versions..

Updating application using InstallShield in VS2012

I am trying to update an application using the Install Shield project in visual studio 2012.
I have read tons of articles/stackoverflow questions about it, and every single one gives the same steps for updating an existing application:
Increment product version
Change Product Code
Build Setup
So I do exactly that. First I build my application, then I build the setup. I find the setup, and I run it. It installs the application as expected.
Then I make a minor change to my application (changing the background color for example), then I:
I build the application
Increment Product version from 1.00.0000 to 1.00.0001
Change the Product Code - I Click the {...} to automatically generate a new one
Make sure the Update Code is the same
Build the setup
Go to the same directory I found the setup in before, and run the setup. It indicates that it installs, but then when I run the program, it is the original program - and in my Control Panel > Programs, there is now 2 instances of the application. And in the install directory of the application, it is still the original files.
I have clicked the resequence RemoveExistingProducts, and still the same thing.
edit: I am just using the basic version of InstallShield that came with VS2012
Anyone have any ideas what I am doing wrong? I have absolutely no idea what I am doing wrong...
As stated within the Upgrade Paths section of InstallShield within VS2012:
If you have released earlier versions of your product and you want to ensure that end users are able to upgrade to the current version without manually installing the earlier version and then also installing the current version, use the Upgrade Paths view to indicate upgrade information.
So in order to upgrade any previous installations, you need to add your application's Upgrade Code to the 'Upgrade Paths'. You can do this from the Solution Explorer:
[InstallShield Setup Project] -> Organize Your Setup -> Upgrade Paths
From that tab, you will right-click on the 'Upgrade Paths' option on the left side of the center pane, and select 'New Upgrade Path...'. You will then be presented with an option to select an installer (.exe or .msi) for your project which will populate the Upgrade Code field. Make sure you set the Min and Max Version fields to specify which versions of your application that you'd like your new installer to upgrade. If you'd like the new installer to upgrade any installed version of your application, then simply set the 'Include Max Version' and 'Include Min Version' fields to no.
You should now be set to build your solution, and when running the new installer, you'll find that you will no longer run into the problems you've specified.

.NET Install Package Sometimes Not Completely Removing Previous Versions

I distribute my application using a VS2008 install package, which normally works great. When I create new versions of the app, I go in and increment the Version property on the install package and verify the RemovePreviousVersions property is set to True.
This works just fine most of the time - I just run the install package for the newer version and the older version is uninstalled and the newer version replaces it.
However, occasionally the install package will run successfully, but when I start the program the old version starts up. Apparently the old version of the .exe is still present.
I end up having to completely uninstall the software and install the new version, which always works, but is a pain.
The file isn't in use as far as I can tell and the install package doesn't tell me to reboot.
Any ideas about what's going on here?
Not a direct answer, but the key difference between an upgrade and an uninstall+ a reinstall is that any custom uninstall steps are not called in 2k8 but are in 2k5.
This is referenced in Visual Studio 2005 -> 2008/10 Service Installer Project Upgrade issue
The other difference related to this is that in 2k8, the files get upgraded based on the version info resource - if your modules dont have newer versions, they dont get replaced.
In some cases whether you strong name also has effects, but I'm pretty confident the last paragraph covers the issue you're seeing.
second is By using orca
Orca is utility to modify msi files.
You can download 'Orca' from following links. http://www.softpedia.com/get/Authoring-tools/Setup-creators/Orca.shtml
Steps:
a. Install orca into your computer.
b. Open orca
c. Drag and drop your msi into orca UI
d. Into left panel it will list the name of tables
e. select property table
f. go to right panel and right click
g. click on 'Add Row'
h. into 'Property' type REINSTALLMODE
i. into 'Value' type amus
j. save msi file
k. and that's it
Now when you install it will overwrite all files.
We need to set REINSTALLMODE property of our msi file to amus.
Following is the link to know more about the meaning of 'amus' http://msdn.microsoft.com/en-us/library/aa371182%28VS.85%29.aspx
There are two ways to do that.
By using msiexec.exe which comes with .NET SDK (if you have VS 2005 or VS 2008 it will come with it, just browse to command prompt of visual studio and you will find it there)
once you find msiexec.exe just type following command to set REINSTALLMODE property to amus for your installer.
msiexec.exe /i foo.msi REINSTALLMODE=amus

Categories