Making app.config permanent

G

Guest

i have a windows app which has an app.config file in the solution. The config
file holds information such as connection string details.

When I create a setup project and include the primary output of my solution
into it then it all installs perfectly....

My issue is this... I may need to amend the app.config file which I do in
notepad on the client machine, however when I need to upgrade the application
I remove the program from the control panel and install the upgraded msi
package... this obviously replaces the amended config file with a "clean"
copy.

How do i ensure that the app.config file which is included in my project is
not deleted when I uninstall the application that it relates to.

Thanks in advance
 
R

Richard L Rosenheim

I use InstallShield with a VB6 application. I had the same issue, both
InstallShield and Windows Add/Remove liked to delete my configuration file
because it was installed as part of the application.

The solution I came up was to install the file with a different name (say,
"Initial.config"). Then, I programmed the application to look for this
file, and if found, rename to a difference name. Because the now renamed
file was not part of the initial installation, the uninstall applications do
not delete it.

Richard Rosenheim
 
S

Sunny

i have a windows app which has an app.config file in the solution. The config
file holds information such as connection string details.

When I create a setup project and include the primary output of my solution
into it then it all installs perfectly....

My issue is this... I may need to amend the app.config file which I do in
notepad on the client machine, however when I need to upgrade the application
I remove the program from the control panel and install the upgraded msi
package... this obviously replaces the amended config file with a "clean"
copy.

How do i ensure that the app.config file which is included in my project is
not deleted when I uninstall the application that it relates to.

Thanks in advance

You can put your custom application settings in a different file, like
Custom.config, like:

<appSettings>
<add key="MyKey" value="Custom" />
</appSettings>

and, in your app.config you will have:

<appSettings file="Custop.config">
<add key="MyKey" value="AllUser" />
</appSettings>

Now, if the Custom.config file is present at the client machine, it's
value will override this one in the app.config. Otherwise, the value in
app.config will be used.

So, this should solve your problem. Once you create Custom.config in the
install dir, it won't be removed upon uninstall, because it was not part
of the install. And the newly installed app.config is going to use it
right away.

Sunny
 
G

Guest

I am working on a similar problem. I am doing exactly the same thing
(renaming files) in Uninstall and Install. Here is the problem, what if
uninstall was called as a result of un installing the application not
upgrading.
This way the user is left with *.config file
Any one has a solution.
How do I find out what triggers(calls) uninstall, an upgrade or uninstall .
Thanks. I am using vb.net.
 
S

Sunny

mach2 said:
I am working on a similar problem. I am doing exactly the same thing
(renaming files) in Uninstall and Install. Here is the problem, what if
uninstall was called as a result of un installing the application not
upgrading.
This way the user is left with *.config file
Any one has a solution.
How do I find out what triggers(calls) uninstall, an upgrade or uninstall .
Thanks. I am using vb.net.

I was peaking of creating a new file with the custom settings. That was
what the OP was after. He needed a way to preserve the customization he
made. Uninstall is not going to delete a file which is not part of the
corresponding install procedure. So, The proposed custom.config file
will survive the uninstall/upgrade.

Sunny
 
G

Guest

This way if the user uninstalls the application, he or she is left with
custom.config file in the application directory. If it is an upgrade keep the
config file and if it is an uninstall dont keep the file(no files should be
left behind). Is there any way to do this. Thanks.
 
S

Sunny

mach2 said:
This way if the user uninstalls the application, he or she is left with
custom.config file in the application directory. If it is an upgrade keep the
config file and if it is an uninstall dont keep the file(no files should be
left behind). Is there any way to do this. Thanks.

This should be done in the installer. You will need something like
InstallShield.

Sunny
 
G

Guest

yes it can be done in vs.net custom action or i figured out a way to do this.
wow.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top