[2005] Setup Project - Config files
I have a VB.NET project to which I have added a setup project in order to deploy it.
Deploying to the application folder I have the Primary Output of my project (which is the project.exe and project.exe.config files).
My problem is that when user install the latest release of my project, the setup procedure replaces all files including my project.exe.config file thereby losing the user's configuration settings (which I use to store the database connection string).
Obviously if I add new settings to the configuration file, I want those added to the user's config files when they upgrade. But I don't want all their existing settings replaced. Is there anyway to avoid this?
Re: [2005] Setup Project - Config files
I don't know if there's a better way but you could use custom actions to read the existing settings before install and reinstate them after install. You don't even have to fiddle with configuration or XML. Just read the entire contents of the file into a string and then write that string back out again afterwards.
Re: [2005] Setup Project - Config files
Hmmm...I suppose so. Although it'll get complicated if there are additions to the config file as part of an upgrade.
There must be a better way surely?
Re: [2005] Setup Project - Config files
What better way could there be if you want to change the config file? You're either going to have to edit the config file to add the new values or overwrite the config file and then re-enter the old values.
Re: [2005] Setup Project - Config files
Well, I would have thought that this would have been such a common requirement for setup projects that there would be some option to integrate the configuration file without overwriting existing values.
Afterall, anyone who makes use of configuration files is not going to want them to be completely overwritten on updates, are they?