views:

1821

answers:

4

How can I specify my app to not overwrite the app.config on the client machines when the app is updated by clickonce?

A: 

Are you trying to preserve settings during an update? If so, look at the application and user settings (in the properties of your project). They are not overwritten during each update.

CStick
not the properties settings, the app.config, with connection strings, ioc configuration, etc...
caiokf
Wouldn't you want that sort of config to be updated on the client
benPearce
no, because for example: clients in my network sometimes uses diferent connectionstrings, and then everytime I deploy the app it resets the app.config
caiokf
In a client system I am working on now, the user configures the data source and other variable which I save in user settings. With user settings, the user's configurations are not lost with each click-once deployment. Here is an article.http://www.codeproject.com/KB/vb/appsettings2005.aspx
CStick
+1  A: 

Move your settings to a different config for each environment you deploy to such as:

app.development.config
app.staging.config
app.production.config

Keep all the settings common to these in your app.config

Chris Ballance
+2  A: 

Background
I asked in the question's comments if users were manually editing the app.config file on their machine after deployment. The original poster responded that they are doing that.

Answer
It looks like the poster wants ClickOnce to deploy the app.config file initially and then not deploy it with future updates to the application. This is a bad misuse of ClickOnce. I don't think there's an easy way to do it, and even if there were I would advise against it. What if in the future you want to add a new setting to your app.config file? How will users get that new setting if the app.config is no longer being updated on their machine?

What I would do instead is store the connection strings as UserSettings. That's exactly what user settings were made for, things that vary from user to user. On top of that, I would probably provide them with a simple form to edit those settings. It would make me nervous having all my users mucking around with their installation files.

whatknott
+1  A: 

if i am not mistaken you need something like this

http://stackoverflow.com/questions/622764/persisting-app-config-variables-in-updates-via-click-once-deployment

Chocol8