7

My ClickOnce app includes an app.config file, which the app does modify according to the user's preferences. It appears, though, that every time my clients get a new version of the app, the app.config file gets reset to its original state.

Is there any way to preserve the app.config file between ClickOnce updates?

Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
  • possible duplicate of [Persisting app.config variables in updates via Click once deployment](http://stackoverflow.com/questions/622764/persisting-app-config-variables-in-updates-via-click-once-deployment) – stuartd Mar 30 '11 at 12:32
  • At first I agreed that it is a duplicate - but on seeing @Daniel's answer, I think this is worth keeping open because it makes the point about using .settings files rather than app.config for what I'm trying to do... – Shaul Behr Mar 30 '11 at 12:39
  • My answer is only a workaround for the problem you're facing. IMO a .settings file with properties using user scope is the way to go. – dcarneiro Mar 30 '11 at 12:51

1 Answers1

3

The app.config is used to store application configurations. For user custom configurations you should be using a .settings file.

The only way I know to keep the user app config is to save a copy of the file before publishing and, post publishing, replace the

publish_dir/version_dir/app.config.deploy

with the copy.

dcarneiro
  • 7,060
  • 11
  • 51
  • 74