Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initializing user.config or app.exe.config during install

I am developing a .NET WinForms application which relies on user.config to store various useful settings such as intranet web service URLs. We would like to make it possible to import custom initial settings as part of the installation. The use case for this is if a company has 100 machines they want to install the software on, and they should all have a reference to the intranet web service in question, this should not need to be set up manually on all the machines.

We are currently using a VS2008 setup project to generate the install package.

Our idea so far has been to enable the installer to make a custom initial .config file with the information (from a template), and then put that in place instead of the default one that the setup project installs.

However, I can't see a way to do this other than these few:

  1. Hardcode the executable name into a custom installer action (deriving from System.Configuration.Install.Installer), in order to use the ConfigurationManager class to determine the .config file path. This would require manual changes to the installer if the executable name changes.
  2. Roll our own configuration classes or file/folder hierarchy to store the settings. This would basically bar us from the advantages of the isolation mechanism (which is also the obstacle here) that .NET provides, if I understand correctly.

Does anyone know of any alternatives, or of ways to make the above two palatable?

I fear the answer may be "don't do this, it defeats the spirit of the mechanism, roll your own settings import mechanism".

like image 619
Chris Ammerman Avatar asked Sep 16 '08 18:09

Chris Ammerman


2 Answers

If you create this application for larger companies, then you should have a look at Group Policy. Unfortunately, it'll bring your application back to the golden age of registry. I understand, that this would be a huge change in your program, but this is the way to this.

However, if the web service's URL is the only thing, you have to setup this way, then GPO might be an overkill. In that case I would hardcode the executable's name.

like image 59
KovBal Avatar answered Nov 10 '22 23:11

KovBal


I know that's not exactly the answer you're looking for, but you should opt for a more "serious" installer. We're using Advanced Installer and it's a blast, does anything and everything you can think of.

like image 28
Shachar Avatar answered Nov 10 '22 23:11

Shachar