0

I'm trying to build a Visual Studio Installer Setup Project that deploys multiple C# projects and some other files. Included in these other files, there are Access Database with forms that needs updates.

To illustrate the problem, I simplified it :

1- Create a new Access Database file, add a simple form to it with a button and a label and save it.

2- Add the file to the setup project;

3- Set DetectNewerInstalledVersion and RemovePreviousVersion to true

4- Build the project.

5- Run the setup executable.

To that point, everything has worked fine

6- Reopen the Access Database file, add a button or a label to the form, save it.

7- Change the Version number of the Setup project, and at the same time the ProductCode as suggested by VS2015.

8- Rebuild the setup project.

9- Reinstall the software.

Expected: the Access data should have been updated with the new button/label.

What is happening: The file hasn't been updated.

Why is that ? I've seen people talking about the Assembly version number of projects included in a setup project, but that's not my case since I'm not deploying the ouput of a project. I'm simply deploying a file that should have been removed during the uninstall process.

If I do the exact same steps as described before but with a text file in which I add text, it works fine, but for some reason in does not work with an Access Database.

What's wrong ?

kaycee
  • 901
  • 1
  • 9
  • 35

2 Answers2

0

If you install a data file, and then run a program that updates it you've added user data to that file, or database. The file overwrite rules don't allow a modified data file to be replaced in the kind of update that VS setups do:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa370531(v=vs.85).aspx

Basically it would be a bad idea to ship a product that installs a database that the user updates with potentially large amounts of data, only to have the new version of the product delete the entire database. It's not clear to me how your app deals with updates (do you want that added button/label just to be completely lost, or do you save them in some way?) so recommending a solution is difficult, but maybe you need an uninstall custom action to delete the database, or on an upgrade you add the updates to the existing DB instead of removing it and starting again.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • In our case, we ship with the main application two Access databases. The first is serving as a front-end and the second as the backend with all the tables that contains the data. Therefore, all the calls made by the objects in the front-end (forms) are linked to the tables in the backend. The backend will never change, so I've set this file to be permanent. The front-end will be subject to changes and this is why I need this file to be able to be replaced. – kaycee May 03 '17 at 19:33
  • I found a solution: see my answer on the post. – kaycee May 04 '17 at 14:55
0

I found a solution. The file wasn't updating because the modified date had changed.

From MSFT site:

Nonversioned Files are User Data—If the Modified date is later than the Create date for the file on the computer, do not install the file because user customizations would be deleted. If the Modified and Create dates are the same, install the file. If the Create date is later than the Modified date, the file is considered unmodified, install the file.

Since I had two Access databases (front-end with the forms, backend with the data tables) and needed only one to be updated (the frontend where the forms are), here's the workaround:

1) Change REINSTALLMODE property to amus instead of the default omus. It will force the reinstallation of all files. To do that, I used a PostBuildEvent as explained here.

2) Set the backend file property Permanent to true

3) Add a Launch Condition: Search Target Machineto check if the backend file exists on the computer. Name it something like BACKENDEXISTS

4) Add a Condition value to the backend file in the File System view to install the file only if it hasn't been found by the Launch Condition. In this case, it will be not BACKENDEXISTS. If this is a first install, it will install the file because it hasn't been found. If this is an update, it will find the file because of the Permanent property and will not replace it.

Community
  • 1
  • 1
kaycee
  • 901
  • 1
  • 9
  • 35
  • 1) The modified data explanation is in my answer - it's not clear to me why you didn't see that or I didn't make it clear. 2) REINSTALLMODE =amus is a bad idea - it will replace all files on the system (later versions than yours) with your older ones. 3) Permanent means permanent. The file will always stay even if you set permanent false in your setup. You'll be hacking like this https://stackoverflow.com/questions/42284519/how-can-i-undo-permanent-flag-in-visual-studio-setup-project – PhilDW Jun 09 '17 at 17:06