Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Override values in app.config from installer msi

Reply
 
Old 10-20-2009   #1 (permalink)
Onno


 
 

Override values in app.config from installer msi

Hi,

I've got a WinForm application (used within our company only) with a
list of constants, paths etc in app.config. A few of these constants
point to paths on our central server which is used as update server
(used to check for updates of the app itself and for several of the
things it used). For this app I've made an installer with Visual
Studio 2005.

Now the paths are fine for 95% of the users, but there is a single
department that want to use their own update server. So a few of the
constants need to be changeable. I do not want to make then really
configurable in the GUI of my app (other users will start to mess with
them) and I do not want build 2 versions of the app or create 2
installers. But I do need some way to let the department specify their
server.

What I thought of is this:
- Prior to running the Installer.msi, that one department double-
clicks a registry file they made themselves (I provide the template).
This registry file enters a path to a custom xml file with values to a
key.
- I move the settings to some 'OverridableSettings' class. Instead of
using AppSettings("ServerPath"), I will use properties from this class
for all fields that need to be overridable. Initially the properties
are set to the values from the App.Config file.
- But if the registry key is present, and the path is valid, the class
loads the values that are in the file.

Now, this will work but I don't have a good feeling about it. Anyone a
better idea? Is it possible to pass parameters to the msi created with
VS2005 and then let the installer pick another app.config or
something? Anything possible with the extended System.Configuration
namespace? (I didn't find anything suitable, but it's quite
overwhelming compared to .NET 1.1 in which I started with the
app.config file)

Many thanks,
Onno

My System SpecsSystem Spec
Old 10-20-2009   #2 (permalink)
Registered User


 
 

Re: Override values in app.config from installer msi

On Tue, 20 Oct 2009 10:36:45 -0700 (PDT), Onno
<onno.willems@newsgroup> wrote:
Quote:

>Hi,
>
>I've got a WinForm application (used within our company only) with a
>list of constants, paths etc in app.config. A few of these constants
>point to paths on our central server which is used as update server
>(used to check for updates of the app itself and for several of the
>things it used). For this app I've made an installer with Visual
>Studio 2005.
>
>Now the paths are fine for 95% of the users, but there is a single
>department that want to use their own update server. So a few of the
>constants need to be changeable. I do not want to make then really
>configurable in the GUI of my app (other users will start to mess with
>them) and I do not want build 2 versions of the app or create 2
>installers. But I do need some way to let the department specify their
>server.
>
>What I thought of is this:
>- Prior to running the Installer.msi, that one department double-
>clicks a registry file they made themselves (I provide the template).
>This registry file enters a path to a custom xml file with values to a
>key.
>- I move the settings to some 'OverridableSettings' class. Instead of
>using AppSettings("ServerPath"), I will use properties from this class
>for all fields that need to be overridable. Initially the properties
>are set to the values from the App.Config file.
>- But if the registry key is present, and the path is valid, the class
>loads the values that are in the file.
>
>Now, this will work but I don't have a good feeling about it. Anyone a
>better idea? Is it possible to pass parameters to the msi created with
>VS2005 and then let the installer pick another app.config or
>something? Anything possible with the extended System.Configuration
>namespace? (I didn't find anything suitable, but it's quite
>overwhelming compared to .NET 1.1 in which I started with the
>app.config file)
>
Not knowing all the niggling details I would consider putting all the
department-customizable settings into their own XML document. When the
installer is run let the standard install point to a file containing
the default settings. If the user selects a custom install let the
user browse and select the custom XML file. All the 'universal'
settings could remain in the app.config.

regards
A.G.
My System SpecsSystem Spec
Old 10-20-2009   #3 (permalink)
Onno


 
 

Re: Override values in app.config from installer msi

> When the
Quote:

> installer is run let the standard install point to a file containing
> the default settings. If the user selects a custom install let the
> user browse and select the custom XML file. All the 'universal'
> settings could remain in the app.config.
>
> regards
> A.G.
Thanks, but is that possible with the standard VS2005 installer?
(can't try right now, but I thought you could not do actions like
letting a user browse for files, etc).

Regards,
Onno
My System SpecsSystem Spec
Old 10-20-2009   #4 (permalink)
Registered User


 
 

Re: Override values in app.config from installer msi

On Tue, 20 Oct 2009 12:16:06 -0700 (PDT), Onno
<onno.willems@newsgroup> wrote:
Quote:
Quote:

>> When the
>> installer is run let the standard install point to a file containing
>> the default settings. If the user selects a custom install let the
>> user browse and select the custom XML file. All the 'universal'
>> settings could remain in the app.config.
>>
>> regards
>> A.G.
>Thanks, but is that possible with the standard VS2005 installer?
>(can't try right now, but I thought you could not do actions like
>letting a user browse for files, etc).
>
It should be possible using a custom action.

regards
A.G.
My System SpecsSystem Spec
Old 10-21-2009   #5 (permalink)
Onno


 
 

Re: Override values in app.config from installer msi

Thanks A.G.!

In the end, I did this:
- I moved all settings that must be changeble to a settings class.
This reads them from an XML file at app startup.
- The installer has a custom action (executed in an Installer class
from my app). This checks if there is a copy of the
XML file in the same dir as the msi of the installer. If so, the
custom action replaces the installed XML file with
the custom copy.
- So on our normal server, the XML file that is in my project is used
because there are no XML files in the release
dirs on our server. The 'special department' can put their changed
XML file in the release dir on their server.
- User sees nothing (no custom install or something). Clean and pretty
me thinks.

I only needed to pass the install and msi path to the installer class.
I found a little trick how to do that
here: http://www.xtremedotnettalk.com/showthread.php?t=77944. You can
do the same for the [SourceDir]
field which is the msi path.

Thanks for your help!
Onno

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Extending app.config with addtional config .NET General
PM override of task status .NET General
Windows Installer stopped in System Config Windows Updates
OVERRIDE on monitor Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46