![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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) > 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 Specs![]() |
| | #3 (permalink) |
| | 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. (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 Specs![]() |
| | #4 (permalink) |
| | 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. >(can't try right now, but I thought you could not do actions like >letting a user browse for files, etc). > regards A.G. |
My System Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||