
rcorless1.5524916639114856E12 asked a question.
Read data from file
Hi
We are trying to implement upgrades on our installers but we have a config file that is updated in each upgrade and it contains the connection string the user uses.
We need a way to read the data source from the connection string so that the update can copy the new config file and then the data source can be copied back into the new config file.
I can do filegrep to get the full line but I only need the value after data source, if there a way to do this with InstallScript?
Thanks in advance,
Rich
Thanks,
Rich
<add key="Main.ConnectionString" value="data source=localhost\sqlexpress;integrated security=SSPI;initial catalog=Main;persist security info=False;packet size=4096" />
I want to search on that file for the "data source=" part and store the "localhost\sqlexpress" part in InstallShield to be used to insert into the new config file.
Thanks,
Rich
Even if I try the example I get a null. If I do an install with "setup.exe /V"/L*v C:\everything.log"" (found in a post by you!) then I get the value for the example one but not mine (which leads me to the fact mine is setup wrong).
In the log it has the value changing for the example one (VALUE_FROM_XML_FILE) but does not have my one changing, the only line in the log file for mine is:
"AppSearch: Property: VALUE_FROM_CONFIG_FILE, Signature: NewSignature11"
This does not explain why it does not work on an upgrade, the purpose is for it to run on an upgrade and not on a normal install, is this not possible? If so, any other way to read the contents of an xml on an upgrade?
Thanks,
Rich
p.s. What would be the correct XPath value for my config file? I have /appsettings[@add='Main.ConnectionString'] returning "value" but that does not work.
p.s. What would be the correct XPath value for my config file? I have /appsettings[@add='Main.ConnectionString'] returning "value" but that does not work. " That XPath query refers to an appsettings element with an attribute named add with attribute value 'Main.ConnectionString'. What you probably want is /appsettings/add[@key='Main.ConnectionString'], which refers to an add element (under an appsettings element) with a key attribute as specified.
Someone has to have done this before, I can't see how it isn't a built in function as it seems a fairly obvious thing to me for an upgrade to do.
Thanks,
Rich
You could of course take this from a custom action approach, at which point you'll have to write similar conditions (and the whole XML update itself), but not worry about making a component only install in those certain scenarios.