'How to force deployment project to update files during installation of newer version?

I have a Deployment Project for my VS2008 C# application. When installing a new version of my application I want to make sure that files are updated with the files contained in the installer.

I want my installer to automatically remove any old version of the installed application. To do that I follow this procedure (also described here):

  1. Set RemovePreviousVersions to True
  2. Set DetectNewerInstalledVersion to True
  3. Increment the Version of the installer
  4. Choose Yes to change the ProductCode

For the assemblies I make sure the AssemblyVersion is set to a higher version:

[assembly: AssemblyVersion("1.0.*")]

Everything is working as intended except for my configuration files (xml files). Since I cannot find a way to "version" these files I cannot make sure that the files are updated if they have been modified on the target machine.

Is there any way to do this and how?

UPDATE: I have tried the approach/solution/workaround found here

  1. Include the file directly in a project with the following properties: "Build Action -> Content file" and "Copy to Output Directory -> Copy always"
  2. Then add it to the deployment project via Project Output->Database->Content Files

Unfortunately it did not make any difference. The behavior is exactly the same.



Solution 1:[1]

If you're willing to use Orca (there may be another way to do this method, but it's the only one I know of) you may be able to set up RemoveFile directives.

See here for a typically light-weight MSDN document -- could be a starting point. http://msdn.microsoft.com/en-us/library/aa371201.aspx

Alternatively you could always create a very simple bootstrapper executable that simply calls "msiexec /i REINSTALLMODE=oums" (or whichever command-line switches are needed). Call it setup.exe if you like...

Better option long-term may be to switch to InstallShield or similar -- VS2010 includes a light version of IS and I believe they're moving away from vdproj projects.

Solution 2:[2]

Add the following property to the Property table of the MSI: Property REINSTALLMODE with Value amus

Note: This will cause all the files in the MSI (versioned and nonversioned) to overwrite the files that are on the system.

Solution 3:[3]

Have you tried the approach/solution/workaround found here?

  1. Include the file directly in a project with the following properties: "Build Action -> Content file" and "Copy to Output Directory -> Copy always"
  2. Then add it to the deployment project via Project Output->Database->Content Files

Solution 4:[4]

I may be incorrect here, and therefore I am exposing myself to down votes, but here goes anyway!

I believe it is on purpose that config files do not automatically get overwritten; the principle there being that you would not normally want your application's configuration overwritten when you install the new version of the program... at least not without numerous warnings and/or chances to merge configuration first.

Having your application configuration get overwritten by an updated version of a program could make for a very upset end user (in this case, web site admin).


Further, I know that sometimes, the developer may be the person doing the deployment. In such a case, this behavior might not seem so logical when deploying a single site to a single server; but when roles are split and/or you have multiple servers with different configurations, this can be a life saver.

Solution 5:[5]

You need to include the new version of your files in your custom installer and manually install these file during Custom Install routine is called This must be applied to any file that does not have version that can be tracked by the installer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Linda
Solution 3 Community
Solution 4 Andrew Barber
Solution 5 Thich Coi Phim