h353655
Posts: 31
Joined: Wed Jun 21, 2017 2:51 pm

Possible bug: lines disappear from config files

I have a .config file containing a line with a property. When doing an upgrade (install new version), the line disappears from the file.

File before install new version

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
  <appSettings>
    <add key="VCPServerURL" value="tcp://server1:13210|tcp://server2:13210|tcp://server3:13210"/>
    <add key="VCPAgentURL" value="tcp://localhost:20002"/>
    <add key="Connection_DefaultTimeoutMs" value="35000"/>
    <add key="Connection_ExtraOperationTimeoutMs" value="1000"/>
    <add key="Connection_GetStateTimeoutMs" value="60000"/>
  </appSettings>
</configuration>

File after install new version:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
  <appSettings>
    <add key="Connection_GetStateTimeoutMs" value="60000"/>
    <add key="VCPAgentURL" value="tcp://localhost:20002"/>
    <add key="Connection_DefaultTimeoutMs" value="35000"/>
    <add key="Connection_ExtraOperationTimeoutMs" value="1000"/>
    <add key="Connection_GetStateTimeoutMs" value="60000"/>
  </appSettings>
</configuration>
server1-3 is gotten from textboxes containing properties server_address1-3 during install
screen shot of settings for element
screen shot of settings for element
settingsforelement.png (67.96 KiB) Viewed 3548 times
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Possible bug: lines disappear from config files

Hello,

It seems that after the upgrade the first element with the "VCPServerURL" key is replaced by the last element "Connection_GetStateTimeoutMs, which is duplicated. Is the screenshot you've attached made on your upgrade project?

We have tested but could not reproduce this issue. Can you give us a more detailed test case?
Please send us both the .AIP projects (old and upgrade) of the installation to support at advancedinstaller dot com so we can investigate them.

By the way, a common implementation of your scenario would be to use an XML Search operation that retrieves the attribute value from the existing config XML file. These values could be displayed by default in the edit boxes on the configuration dialog of the setup. Please take a look on our article : Creating an XML Search

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
h353655
Posts: 31
Joined: Wed Jun 21, 2017 2:51 pm

Re: Possible bug: lines disappear from config files

Mail sent to support box. Thanks.
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Possible bug: lines disappear from config files

Hello,

Thank you for sending us the project. We have investigated it and the issue seems to be related to the fact that your XML file contains multiple elements that have the same name.

In order to enhance the localizing precision of matching elements, you can use identifier attributes to pinpoint an exact element from the file, in case several nodes have the same ancestors. By enabling this option only target elements that have an attribute with the same name and value set here will be considered a match for the update.

Please go to XML File dialog and choose the first "add" element, go to "Attributes" tab, double click on the "key" attribute and choose "Is identifier attribute". Repeat this process for all "add" elements.

In this way, when the XML file is built, the Identifier Attribute of an element is used to identify it, as there are multiple elements with the same name.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
h353655
Posts: 31
Joined: Wed Jun 21, 2017 2:51 pm

Re: Possible bug: lines disappear from config files

Thanks, that worked.

I guess that's just one more ting to remember when using a C# .config file.

I thought a standard appSettings line
<add key="something" value="something else"/>
would look for the key "something" as standard.
But now that I know it's easy :-)
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Possible bug: lines disappear from config files

Hello,

You are welcome!
Please let me know if you have any other questions.\

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”