jfuhr
Posts: 41
Joined: Wed Mar 19, 2008 4:52 pm

How to edit .NET config file in 10.7

In earlier versions of AdvancedInstaller, I was able to update an installed web.config file by creating a new XML file and giving it the same filename.

However, after upgrading to 10.7.1, if I try to rename the XML file to 'web.config' the UI gives me an error stating that the file already exists.

Is there a new way to update a .config file that is being installed?
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to edit .NET config file in 10.7

Hi,

I tested your scenario, but I cannot reproduce the behavior. Can you make sure that there is no more than one file with that name in the same folder? Otherwise, can you please send us the AIP (project file) to support at advancedinstaller dot com so we can investigate it and try to find the problem?

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jfuhr
Posts: 41
Joined: Wed Mar 19, 2008 4:52 pm

Re: How to edit .NET config file in 10.7

Well this is strange.

I still kept getting "filename already exists" so I changed it to the same name, but with a lower case letter. i.e. ARImport.exe.config is the existing file, so I used arimport.exe.config and it accepted it.

It then let me change it to ARImport.exe.config.

I'll try creating a new project and try it again, this time with screenshots. If it breaks, I'll repost.
hgxu2013
Posts: 28
Joined: Wed Dec 11, 2013 1:50 am

Re: How to edit .NET config file in 10.7

Hi There,
I am currently implementing what this user was doing and I ran into exactly the same issue.
Please help me to understand why it doesn't allow to overwrite the same file name.
In my File and Folder, i create a new XML file and then i renamed it web.config.
Along with the XML file, i have another *.config with the same name. So, in the directory there are 2 web.config. one is the actual configure file the other one is the new XML file that I set up all the values that i like to update based on users UI inputs. I got it to work. However, my problem is, I have to preset the actual configure file. I would like to be able to allow user to select the configure file he or she would like to use, I then take the file selected by user and overwrite the actual configure file. Finally, the new XML File i created earlier should base on the latest web.config and manipulate the values accordingly. I am now stuck where I couldn't do it. Please advice.
I am using version 10.0 Advanced Installer.
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to edit .NET config file in 10.7

Hi and welcome to Advanced Installer forums.

In order to have more XML files with the same name, but with different configurations and install only one of them based on a condition, you can follow the steps described in the How do I install two files with the same name in the same folder tutorial.

Let us know if this helped, otherwise give us more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
hgxu2013
Posts: 28
Joined: Wed Dec 11, 2013 1:50 am

Re: How to edit .NET config file in 10.7

Hi There,
THank you for the tip. It worked. Now I need your assistance that is related to what I am trying to accomplish. Currently I tested whether it worked or not using Environment variable that is checked by Radio button, whether it is QA or Development.
However, I am being requested not to use Radio button to determine the environment, rather I am asking to use BrowseForFile based on user selected the folder to find the file to use as web.config. We have web.qa.config, web.development.config.
So, i got stuck where I need to get the filename of the file that is selected using BrowseForFile custom action. I would like to know how I determine if the file is web.qa.config or web.development.config.
THanks in advanced.
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to edit .NET config file in 10.7

Hi,

You're welcome.

As described in the Select an external file during the installation tutorial (step 5), the [MY_FILEPATH] property will contain the full path to the selected file (including the filename).

So, in order to see which file the user chose, you can create a simple custom action that parses the [MY_FILEPATH] property and gets the name of the file from it.

Just let us know if you have any other question.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
hgxu2013
Posts: 28
Joined: Wed Dec 11, 2013 1:50 am

Re: How to edit .NET config file in 10.7

Hi There,
I am not able to figure out how to do it. Would you be able to assist me? I am kind of new to Advanced installer. Should i store the value into the registry and use it to compare?
Please help.
THanks in advance,
hgxu2013
Posts: 28
Joined: Wed Dec 11, 2013 1:50 am

Re: How to edit .NET config file in 10.7

BTW, i just upgraded to 10.8 will this helps me to do what I wanted to do, extract filename.
Thanks,
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to edit .NET config file in 10.7

Hi,

In order to achieve this you can follow the steps below (this steps are implemented in the AIP file that I attached to this post):
- create a simple custom action that uses the [MY_FILEPATH] property to parse it and get the name of the selected file and display a message box with that name
- add the custom action without sequence in the Custom Action page (in the attached project it is called "ExecuteScriptCode")
- go in the Dialogs page and select the [Next] button of the "BrowseForFile" dialog
- in the " Published Events" tab create a new "Execute custom action" event and select the "ExecuteScriptCode" custom action from the "Argument" tab
- set the "MY_FILEPATH" property as a condition for it (if the user does not select any file, the custom action will not be executed)
- build and run the project

Just let us know if you have any other question.

Best regards,
Eusebiu
Attachments
BrowseForFile.aip
(14.29 KiB) Downloaded 605 times
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
hgxu2013
Posts: 28
Joined: Wed Dec 11, 2013 1:50 am

Re: How to edit .NET config file in 10.7

Hi There,
I like to thank you for your wonderful support. I really appreciate your quick response! I got it to work.
Again, thank you for great support!!!!
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to edit .NET config file in 10.7

You're welcome. Glad to help.

Just let us know anytime you need help.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
hgxu2013
Posts: 28
Joined: Wed Dec 11, 2013 1:50 am

Re: How to edit .NET config file in 10.7

HI There,
I spoke a bit too early. Somehow the value passing back from vbscript was not able to recognize by component property's condition in the Organization, for web.dev.config.
I created a value called SelectFileName and set web.qa.config as a default value.
In the vbscript you provided earlier I passed back by this statement Session.Property("SelectFileName") = tempfn. tempfn at this point is equal to web.dev.config which selected by user.
So, the component web.dev.config's condition should be the one that got updated its configuration file based on all other values entered in the text fields by user through UI, during installation, XML parameters. Its condition is set to SelectFileName = "web.dev.config". So SelectFileName is now equal to string "web.dev.config"
It didn't. However if user select web.qa.config from the ui, it updated the XML parameters correctly for this particular component, because its component condition was set, likes this SelectFileName = "web.qa.config".
Please advice.
THanks
hgxu2013
Posts: 28
Joined: Wed Dec 11, 2013 1:50 am

Re: How to edit .NET config file in 10.7

Hi There,
Would you be able to advice me what I have done wrong that the value passed back from vbscript was not being recognized? It is very critical that I have to rollout the product by next week. Your attention is highly appreciate.
If i have to send you my .aip, please let me know. I would like to be able to just send directly to your attention. I would prefer not to expose this to forum, it is important to the company.
THanks again and I hope to hear back from you today. So, I can start trying it out. BTW, i found a few articles how to pass back the values, I tried them and unfortunately it is still not working right. Do you think it has to do with the order of the Diaglogs?
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to edit .NET config file in 10.7

Hi,

First off all I apologize for the delayed reply, but I was not in the office in the last days.

Your problem might be caused by the fact that you use a Private Property (contains lower-case letters in its name) instead of a Public Property (contain only upper-case letters in its name). Can you try to use a public property (i.e. SELECTFILENAME) and see if it works?

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”