Can we instruct Visual Studio Setup to keep existing files for re-install?
Asked Answered
A

2

8

I have a Windows Forms application with an installer (.msi) already created with Visual Studio. I am now creating a new installer for version 2.0 with the property RemovePreviousVersions set to true.

Now, when I install 2.0 over 1.0 it removes 1.0 and installs 2.0 completely.

Is there a way that I can tell the installer if you find some files already installed (like .xml files used for data) then don't override them?

I am trying to have my 2.0 installer serve the 2 purposes:

  • Install from scratch for new users
  • Existing users will upgrade but not lose their customizations
Abm answered 22/6, 2009 at 16:31 Comment(0)
K
16

The deployment project in VS does not overwrite files. What happens is that since you have RemovePreviousVersions set to true, when you change your program file version and the ProductCode GUID of the setup project, it will first uninstall the previous version and then will do a clean install of the new version.

To make sure some files don't get overwritten, I usually exclude them from the Content or Primary output files (wherever they are located) and then add them separately to the setup project. Doing this, you can individually set properties for those files. The property you are looking for is called Permanent" that if set to true will never uninstall the file in question, and therefore will never overwrite it with a new version. The only drawback with this is that when you uninstall the product, the Permanent files will not get removed from their target locations, but in my case (usually local DB files), that's a good thing ;)

Cheers!

[edit] The above is true for VS 2008 SP1. Haven't tried it on other versions, so hopefully you are using the same VS version or it works for the version you use.

[edit2] Oh, also you could also use the "Condition" property to achieve something similar. If you do that, make sure that "Transitive" is set to True so the Condition is always evaluated. Haven't tried it with Conditions, but that's another option you could look at. Other than these 2, I think that's pretty much it for VS deployment projects.

Kaluga answered 23/6, 2009 at 1:29 Comment(2)
The rules for file replacement are [here] (msdn.microsoft.com/en-us/library/aa370531(v=VS.85).aspx).Abrahan
Using VS2010 SP1. It is not working for me... The file is replaced even if Permanet set to true !!! It is replaced when the date/time of the file on disk is older than the date time of the package creation. In VS2010 not SP1, it was replaced when the date time of the file on disk was older then the date time of the file used for creating the package. Setting date time of the source file to 01/01/2001 solved me lots of troubles, but it is not working anymore !!!Prowel
H
2

When I was in a similar situation what I did was:

The files that were customized by each user and should NOT be touched by the installer were NOT included in the MSI (NOT in the Visual Studio Setup Project). When the app was run for the first time I generated the XML files through the code.

The files that were static (e.g. data that was used to populate Dropdownlists) I included in the MSI and I can update those by building a new MSI with Visual Studio.

Basically don't include customizable files in your MSI project. Create them in code for new users.

I never looked into telling the MSI not to update certain files that are included in the MSI file. The solution I came up with was perfect for me. I don't know if it can be done.

I hope this helps.

Hawkbill answered 22/6, 2009 at 17:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.