|
Hello all,
We have an installer that puts a default config file in the application path at setup. It contains various settings that the user can modify when using the application. The problem is that these changes get overwritten when an upgrade is installed. I need to save off the current default config file before installing (if it exists) and then ask the user post install whether they want to merge the config files, ignore the old or ignore the new. Ithought I couldaccomplish this with the following:
A. Override OnBeforeInstallin a custom installer class to save off the existing config file B. OverrideOnCommittedin a custom installer class to give the user options to merge, use old or use new config fies
But the old config file has already been deleted before OnBeforeInstall is ever called.
1. How and where do I hook the installer process early enough to save off the existing config file 2. The installer won't know where the existing config has been installed so I will need to modify theinstaller to tuck that information away somewhere - Is a registry key the best place to do this
Thanks in advance for any ideas and/or suggestions! | | j2associates Wednesday, August 26, 2009 10:39 AM | Hello, Thanks for your feedback. From your description, I know that you cannot use Application Settings architecture since your application has already deployed to the clients. My suggestion is that you can try to write your own bootstrapper to deal with this case. 1. The bootstrapper copies the saved settings(connection string) to a temporary folder 2. The bootstrapper start the upgraded MSI package 3. The bootstrapper merge the config file. More info http://msdn.microsoft.com/en-us/library/aa367832%28VS.85%29.aspx Thanks, Rong-Chun Zhang MSDN Subscriber Support in Forum If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - Marked As Answer byRong-Chun ZhangMSFT, ModeratorMonday, September 21, 2009 11:15 AM
-
| | Rong-Chun Zhang Wednesday, September 02, 2009 8:28 AM | Hello, Thanks for your post on MSDN forum. To persist the configuration file, I have a few suggestion for how we design the application and the installer.
- We can use the Application Settings(recommended way).
Application Settings has two scope of settings -- user scope and application scope. The user scope settings is actually stored in the user's profile won't be removed when we uninstaller the application. Therefore the settings is still on the client machine when upgrading the application. When user start up the application, it will load the stored user settings. It not only keeps the settings when upgrading, but also has different settings for different user. http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx
- Set the Permanent Property of the configuration file to true, then the file won't be removed when the application is uninstalled. However, if try this suggestion, the configuration file in the new package should not be newer than the installer one. See the file version rule.
http://msdn.microsoft.com/en-us/library/aa368599%28VS.85%29.aspx
- Let the application itself manage the configuration. This means that you can let the application generate the configuration somewhere on the client(e.g. program data folder).
- Create a bootstrapper that will copy the configuration file before starting up the upgrading process. But this is a little bit complex to do.
Thanks, Rong-Chun Zhang MSDN Subscriber Support in Forum If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - Edited byRong-Chun ZhangMSFT, ModeratorThursday, August 27, 2009 5:34 AMformatting
-
| | Rong-Chun Zhang Thursday, August 27, 2009 5:33 AM | Hello,
I am writing to check the status of the issue on your side. Would you mind letting me know the result of the suggestions? If you have any additional question, welcome to post here.
Have a great day!
Thanks, Rong-Chun Zhang
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. | | Rong-Chun Zhang Monday, August 31, 2009 7:44 AM | Hello, Thanks for the followup. Due to other pressing issues, I have not been able to get back to this project and try the suggestions you were kind enough to post. I was able to find and do the walkthrough Create Database at Installation.rtf: http://msdn.microsoft.com/en-us/library/49b92ztk(VS.80).aspx. Based upon your suggestions and what I learned in the walkthrough code, I am going to try the following: A. Remove the config file from Installer list of files to copy B. Create an Installer class C.Override the OnCommitted method in the Installer class to manage the config file D. Create a Custom Action for the Installer Commit to call my Installer class Does this sound like a workable and reasonable plan? If so, how do I determine the following when the Setup project is running and installing: A.Current project path from which the new config file will be copied B. Application folder the user selected when prompted for an installation path by the Setup project Thanks again for your helpfulness and followup! | | j2associates Monday, August 31, 2009 10:54 AM | Hello, I am not sure how you managed the config file in the custom action, so I am not sure whether it will work. However, I really don't think it is a good idea to persists the config file in a Custom action. As I said, it recommend you using the application settings with your application, then you donot need to manually to persists the config file, you just need to create a upgraded package. http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/ce92966b-98d8-4ac4-a768-431931d11de2As for your new questions: A: To get the location where the product is installed, we need to know the ProductCode of the MSI package. We can then get installed location from the WMI class Win32_Product Class using the ProductCode. We can also get the installed loaction with the help of registry. http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/2177bf0e-04dd-43da-95a7-22bcda8d7c26B: We can pass the TARGETDIR property to the Custom Action by set CustomActionData property, and then get the value from the Context property of the Installer class. See the following thread for a sample. http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/cf730163-d34a-4bee-8adc-71ce69540b8dThanks, Rong-Chun Zhang MSDN Subscriber Support in Forum If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. | | Rong-Chun Zhang Tuesday, September 01, 2009 10:21 AM | Assuminmg I understand what you're trying to do, there's nothing you can do in a custom action to save the config file because custom actions always run after all the files have been installed.
If you are using a VS 2008 setup project you should not be seeing an issue here. A RemovePreviousVersions upgrade will not replace data files that have been changed - that's the way the file update rules work. If you are used to VS 2005 setup projects they always replaced everything because they are effectively an uninstall of the older product followed by an install of the new one. Phil Wilson | | PhilWilson Tuesday, September 01, 2009 6:42 PM | Perhaps I can clarify what I am attempting to do. We have an app used by DBA types, all of whom are responsible for different servers and hence need different connection strings, etc. To maintain consistency within the app, the variable stuff such as the various connection strings, etc has been pulled out of the app config files and placed in a separate xml file. The app is originally installed with a default set of data in the separate xml file used as a starting point. The DBAs are free to modify this as they see fit based on their individual circumstances.
When a new app version goes out, it needs to do one of 2 things. If the separate xml file is not present in TARGETDIR, then it needs to copy the default xml file. If it is present, then it needs to merge them so the DBAs do not lose their current settings. I apologize if the lack of more detailed information earlier in the process caused a bunch of confusion. | | j2associates Tuesday, September 01, 2009 10:23 PM | Hello, Thanks for your feedback. From your description, I know that you cannot use Application Settings architecture since your application has already deployed to the clients. My suggestion is that you can try to write your own bootstrapper to deal with this case. 1. The bootstrapper copies the saved settings(connection string) to a temporary folder 2. The bootstrapper start the upgraded MSI package 3. The bootstrapper merge the config file. More info http://msdn.microsoft.com/en-us/library/aa367832%28VS.85%29.aspx Thanks, Rong-Chun Zhang MSDN Subscriber Support in Forum If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - Marked As Answer byRong-Chun ZhangMSFT, ModeratorMonday, September 21, 2009 11:15 AM
-
| | Rong-Chun Zhang Wednesday, September 02, 2009 8:28 AM | Hello Rong-Chun Zhang,
Many thanks for sticking with me on this thread! I am up to my eyeballs in alligators on another project, so I won't be able to get back to this for a bit. Your explanations and links have been very helpful and I look forward to digging into your last response soon. Do you happen to have a link to a walkthrough or example of how to use the bootstrapper process? Thanks again for all of your help! | | j2associates Thursday, September 03, 2009 4:29 AM | Hello
>Do you happen to have a link to a walkthrough or example of how to use the bootstrapper process?
Technically speaking, a bootstrapper is a application that will check and run other processes sequencingly. Here is a sample for your reference. http://www.microsoft.com/downloads/details.aspx?FamilyId=BF253CFD-1EFC-4FC5-BA7E-6A6F21403495&displaylang=en
Thanks, Rong-Chun Zhang MSDN Subscriber Support in Forum If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. | | Rong-Chun Zhang Friday, September 04, 2009 8:50 AM | Hello,
I am writing to check the status of the issue on your side. Would you mind letting me know the result of the suggestions? If you have any additional question, welcome to post here.
Have a great day!
Thanks, Rong-Chun Zhang
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. | | Rong-Chun Zhang Tuesday, September 08, 2009 10:13 AM | Hello,
The link to the Bootstrapper sample posted on Fri, Sept 4, crashes and burns with the old Microsoft has encountered a problem and must close when I click the download button. I am using IE 8.0.6001.18702. Thanks again for your help! | | j2associates Wednesday, September 09, 2009 2:04 AM | Hello, I tried on my side with IE 8.0.6001.18702, it worked well on my machine. You can try to download it on another machine. Thanks, Rong-Chun Zhang
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. | | Rong-Chun Zhang Wednesday, September 09, 2009 2:26 AM | Hello,
It has been several days, have you got any progress on this issue? If there is anything else we can help, welcome to post here.
Thanks, Rong-Chun Zhang
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. | | Rong-Chun Zhang Monday, September 14, 2009 11:38 AM |
|