views:

261

answers:

4

Hi,

I'm using WiX to create a windows installer. Unfortunately my installer overwrites a config file on every update. What I really want is, that the installer only creates the file if it is not found.

Thanks and regards, forki

+2  A: 

I sure someone will come up with a proper answer, but as a backup:

You could have the installer create a default configuration file, and then have your application copy the default file to the normal configuration file, if the normal configuration file is not present. This also provides an easy way to reset the application to factory default (just delete the configuration file).

Douglas Leeder
Nice idea. But this doesn't work in my scenario - I can't change the app code.
forki23
It seems you accepted the wrong answer, man :) Dave Andersen below proposed a good workaround for your case.
Yan Sklyarenko
@Yan Indeed, Although in my defence my answer was much more timely...
Douglas Leeder
The original poster does appear to still be around, so maybe he'll come back and change the selected answer. I guess the tyranny of accept rate got to him.
Douglas Leeder
+2  A: 

You can change the default behavior with REINSTALLMODE property. It defaults to "Reinstall if the file is missing or is an older version", which is logically correct, as for me. But you can experiment with other values to find the behavior you need.

Hope this helps.

Yan Sklyarenko
REINSTALLMODE seems to be a global property. I only want to save one file.
forki23
+2  A: 

This really is an application bug, not a setup issue.

You shouldn't be "installing" data that is later editable by the user, Windows Installer records the size, modification date and hash value of files installed. That way if the file is later discovered to be "corrupt" it can be repaired.

We install a default config file that is copied to the user config when none is found, that way Windows Installer never even knows about the user editable config and so doesn't do any replacement.

sascha
As I've written above - unfortunately I can't fix the app.
forki23
+3  A: 

The Component @NeverOverwrite="yes" attribute might be the solution to this problem.

From the WiX help documentation:

If this attribute is set to 'yes', the installer does not install or reinstall the component if a key path file or a key path registry entry for the component already exists. The application does register itself as a client of the component. Use this flag only for components that are being registered by the Registry table. Do not use this flag for components registered by the AppId, Class, Extension, ProgId, MIME, and Verb tables.

Dave Andersen
Well, this seems to be a solution to the problem above, assuming the application can't be changed, just installer...
Yan Sklyarenko
I don't know how heavy weight making the config file into it's own component, or whether the Registry table restriction matters.
Douglas Leeder