philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Values over written during update

Hi,

I'm sure I've posted about this or seen another topic but can't find it. I've just got my auto updater working silently in the background but when the update runs i get the following behaviours:

1) I collect tag values, system type and system location. These are set at the time of installation and written out to a config file. When the updater runs without any human interaction this config file is overwritten so i end up with

Type = "Select One"
location = "Select One"

How can i retain the original values during the update?

2) as part of the installation, i provide a resolvable machine name (in my test environment this is called "apache"), the installer builds a url from this which becomes http://apache/config.conf - During the update because i do not specify this path again the installer variable becomes blank giving me the url "http://config.conf". This causes the installer to fail during the update.

For now, i can hard code this as a default value which would work for testing, however in production this value could be different depending on the client and hard coding a defaut value could result in the same failure if this default doesn't match the one we provided.

How can i stop the updater from trying to download the config file again during install?

Ideally when this installs, i don't want any user interaction so the values need to remain as they were during installation. How can i achieve this?

Bonus points)

I have an optional field, called "MULTI_SITE_LOCATION" - This is used when we isntall our application on systems/services that are spread across multiple sites.

Currently i write my tag values to a file using the "edit text file update" - How can i work this so that the "MULTI_SITE_LOCATION" tag and value is only written when they have been entered?

I need to avoid sending any unwanted tags to my database due to data cardinallity.


Can any one offer some advice? I can amost taste victory!
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Values over written during update

Hello Phil,
1) I collect tag values, system type and system location. These are set at the time of installation and written out to a config file. When the updater runs without any human interaction this config file is overwritten so i end up with
Most probably, you create the config file using the properties of the controls from your dialogs. Most of the installation packages use custom properties for retrieving information from the user. Since the values of these properties are specific to the install process which sets them, the values set in one process cannot be used in another process (for example the properties set in the first installation don't have the same value during a repair). This can be solved by writing the values of the properties into the registry.

An easy way of doing this would be to set the "Set persistent property" attribute for your properties. Let's work on an example so we can better understand:

Let's say you have an edit box in one of your dialogs. By default, this edit box's property is named: EDIT_1_PROP. In order to make this property persistent, you can proceed as it follows:

1. go to "Install Parameters" page

2. create a new property as it follows:

Name: EDIT_1_PROP
Value: blank
Comments: <insert_some_comments_here>

"Set persistent property" attribute set.


Important: it is important to have a comment to the property declaration, so we can leave its value field blank.

Upon installation, this property will be saved in the registries. To retrieve the path of where it is saved, you can proceed as it follows (on an Enterprise license or above):

1. open your project

2. go to "Table Editor" page

3. click on the "Registry" table. There, you can find your property. By default, it can be found under the following key:

HKLM:\Software\[Manufacturer]\[UpgradeCode]
2) as part of the installation, i provide a resolvable machine name (in my test environment this is called "apache"), the installer builds a url from this which becomes http://apache/config.conf - During the update because i do not specify this path again the installer variable becomes blank giving me the url "http://config.conf". This causes the installer to fail during the update.
I think that this can also be solved with the above approach.
I have an optional field, called "MULTI_SITE_LOCATION" - This is used when we isntall our application on systems/services that are spread across multiple sites.

Currently i write my tag values to a file using the "edit text file update" - How can i work this so that the "MULTI_SITE_LOCATION" tag and value is only written when they have been entered?
I am not quite sure I understand your scenario here. Could you please give me some more details about what you want to achieve? To be fully honest with you, I do not know what you mean by "when they have been entered".

Hope the above information helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Re: Values over written during update

Hi Catalin,

Thank you for your answer. I did some reasearch afterwards and read about the persistent properties which seems to be working, I'm only testing on one machine though. However i had not realised giving it a comment meant i could give it a default value of blank. I'll apply the comments to my installer now.

Regarding the multi site tag, I can add this to my tags file during installation but i only want to add the multi site tag value if it exists. SO there are 3 tags in total

Type = required
Location = required
Site = optional

I only need to write the "multi site" value to this file when the checkbox has been checked and a value entered.

So scenario 1 i do not specify a "multi site" value. So when the installer completes it writes a file called "Tags.conf"

Code: Select all

# Global tags can be specified here in key="value" format.
[\[]global_tags]
   Type = "[SYSTEM_TYPE_TAG]" # System Type Tag
   Location = "[SYSTEM_LOCATION_TAG]" # System Location Tag

obviously SYSTEM_TYPE_TAG and SYSTEM_TYPE_LOCATION would be replaced by the values entered during installation.

Scenario 2, i choose "multi site" and enter the additional tag information. This writes the same Tags.conf file but with the additional tag value.

What i'd like to achieve is something like

If MULTI_SITE_VALUE is not empty, write the 3 values to the tags.conf file
Else
just write the two required values.

Basically, is it possible to add an if/else statement inside the "Edit Text File Update" to do this? If not, how could I achieve this?

I can't include the tag as a default tag, it would either cause the application to stop functioning due to the null value. Or worse, it would write the tag to my database with a null value which would be no good for my data.

I do have another question as well relating to the same dialog. I'll post this in a new topic though.
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Values over written during update

Hello Phil,
Thank you for your answer. I did some research afterwards and read about the persistent properties which seems to be working
You are always welcome.

I am glad you got this working.
However i had not realised giving it a comment meant i could give it a default value of blank. I'll apply the comments to my installer now.
Yes, we have added this functionality specifically for users to be able to declare an empty property (it was requested a lot).

Thank you for the explanation about the "multi site tag". I think it is clear for me now what you want to achieve.

Unfortunately, it is not possible to add an if - else statement to the "Edit Text File Update" dialog. However, this can still be achieved. For instance, you can proceed like this:

- have 2 text file updates:

1. if the condition is true, execute the first one
2. if the condition is false, execute the second one

In order to create a conditional text file update, you can have a look over the following thread, in which (hopefully) I have explained clear enough how this can be achieved:

viewtopic.php?t=40454#p108576

(Please let me know if you have any question in what regards my solution above)

Beside that, another way of conditionally creating a text file update would be the solution presented by my colleague Danut in the following thread:

viewtopic.php?t=29327#p77755

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Re: Values over written during update

Thank you Catalin, This works for me.

Becasue I wasn't able to include two text files (with the same name) i think it might be better if i leave my original tags file as is and use the method you explained to write a "site.conf" file containing the ifnormation I need.

I plan to build specific configs during installation (for SQL/MySQL servers and exchange servers). I think i can use the same method to dictate which config i need to create.

Before i do that though, I have a question about best practices.

At the minute everything in my installer is all part of one main feature/component. If i want to add functionality to build configs during installation should i be creating each of those as individual features inside my installer?

SO at the moment if i go to "Organisation" I can see "MainFeature"


Should i add the extra sections for SQL and MySQL underneath the main feature or is it best practice to create each one of those as its own feature? I figure if i find out now, then it might save me some headaches in the future when i need to do updates :)

Thanks
Last edited by philb1208 on Tue Sep 24, 2019 9:52 am, edited 1 time in total.
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Values over written during update

Hello Phil,

You are always welcome. I am glad the solution worked for you.

In what regards your question, indeed, as you have mentioned, organizing your setup into multiple features may prove to be helpful in the long run.

So, here, my answer is yes, you should be organizing your project into features. You can find more information about this in our "Organization Page" article.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Re: Values over written during update

Thanks Catalin, I'm not much of a developer so not quite sure of the best way to proceed. In my head, the separate features seems like the right choice but i wanted to make sure.



Thanks! :D
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Values over written during update

You are always welcome, Phil.

Yes, you were right about that.

Best regards,
Catalin :D
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”