Using XmlMassupdate how to change:
Change this:
<applicationSettings>
<StackOverflow.Properties.Settings>
<setting name="StackOverflow_References_References" serializeAs="String">
<value>OLDVALUE</value>
</setting>
</StackOverflow.Properties.Settings>
</applicationSettings>
To this:
<applicationSettings>
<StackOverflow.Properties.Settings>
<setting name="StackOverflow_References_References" serializeAs="String">
<value>NEWVALUE</value>
</setting>
</StackOverflow.Properties.Settings>
</applicationSettings>
I had to update to a newer version of xmlmassupdate to get this to work.
Related
Recently I posted a couple of errors I was having, relating to app.config in a VB project. Andrew Morton kindly pointed me to an existing answer which resolved the first part of the issue, but I've since found that I still can't add/update variables in app.config via the Settings dialog in the project properties, nor can the Settings dialog read the app.config file.
The error message is:
an error occurred while reading the app.config file. the file might be corrupted
If I manually change the variable in app.config the program I'm coding still finds the old value as it's taking it from Settings.Designer.vb, and that's not getting updated when I change the variable in Settings as the platform isn't reading the app.config.
I've (again) run the app.config through an XML checker, all fine. I read one solution for this issue, which suggested the cause can be duplicate elements in the 'sectionGroup' area of app.config, but mine doesn't appear to have duplicate elements (app.config posted).
Steps I have tried are:
Removed and re-added the project from the solution.
Updated VS.
Repaired VS.
Deleted the app.config file and the variables from the Project Properties - System dialog, then added a new app.config and recreated the variables in the System dialog.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler"/>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" >
<section name="Doghunter.My.MySettings" type="System.Configuration.ClientSettingsSection, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" requirePermission="false" />
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="Doghunter"/>
</sharedListeners>
</system.diagnostics>
<applicationSettings>
<Doghunter.My.MySettings>
<setting name="TestKey" serializeAs="String">
<value>Henry</value>
</setting>
<setting name="NewKey" serializeAs="String">
<value>Moscow</value>
</setting>
</Doghunter.My.MySettings>
</applicationSettings>
</configuration>
Rebuilding the project as a Windows Forms Application (.Net Framework 4.7.2) resolved it.
Originally chose 'plain' Windows Forms Application, which used 5.0
No idea why this is the case, but now works so all good.
I am new to Wix and up till now I was able to manage it but now I want to update existing value of a Sub node from a config file. Below is my code to update it. But I get the error: failed to find the node.
<Component Id="ServiceIPAndPortSave" Guid="*" Directory="INSTALLFOLDER">
<CreateFolder/>
<util:XmlConfig
Id="UpdateIP"
On="install"
File="[INSTALLFOLDER]ProjectName.exe.config"
Action="create"
Node="value"
ElementPath="//configuration/userSettings/ProjectName.My.MySettings/setting[\[]#name='IPAddres'[\]]/#value"
Value="[SERVICEIP]"
/>
</Component>
And below is the format for my config file:
<configuration>
<userSettings>
<ProjectName.My.Settings>
<setting name="IPAddres" serializeAs="String">
<value>127.0.0.1</value>
</setting>
</ProjectName.My.Settings>
</userSettings>
</configuration>
Your XPATH expression is incorrect, you have two problems:
Your reference to the ProjectName.My.Settings element is invalid, you are using ProjectName.My.MySettings.
Your reference to the value element is invalid, you are using attribute notation.
And while not incorrect, you are rooting the search from anywhere by using // at the start of your query.
Try:
/configuration/userSettings/ProjectName.My.Settings/setting[\[]#name='IPAddres'[\]]/value
My sample.xml file is below
<deployment>
<definition type="xpath">
<xpath>configuration/Settings/add[#key='NetworkPath'][#value]</xpath>
<attribute>value</attribute>
<value>http://www.google.com</value>
</definition>
</deployment>
I want to fetch the value "http://www.google.com" corresponsing to xpath "configuration/Settings/add[#key='NetworkPath'][#value]". I am writing below XmlPeek task but it is not working
<XmlPeek XmlInputPath="C:\Sample.xml"
Query="configuration/Settings/add[#key='NetworkPath'][#value]">
<Output TaskParameter="Result" ItemName="Peeked" />
</XmlPeek>
<Message Text="Peeked value is #(Peeked)"/>
There might be some confusion about XPath.
If you want to retrieve htttp://www.google.com from Sample.xml you need to apply this query:
<XmlPeek XmlInputPath="Sample.xml"
Query="/deployment/definition/value/text()">
<Output TaskParameter="Result" ItemName="Peeked" />
</XmlPeek>
If you want to extract the path configuration/Settings/add[#key='NetworkPath'][#value]/#value it corresponds to another Xml file having this form:
<configuration>
<Settings>
<add key="NetworkPath" value="http://www.google.com"/>
</Settings>
</configuration>
Check out some XPath examples.
I have a manifest file for an application which looks something like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity name="xxx.exe" version="1.1.0.0" type="win32" processorArchitecture="x86" />
<file name="xxxxxxxx.ocx" hashalg="SHA1">
<comClass clsid="{4xxxxxxx76-D693-4156-93BA-B938A56F15D3}" description="" threadingModel="apartment" />
<typelib tlbid="{8xxxxxx-3A75-4708-993D-6E0CD9564072}" version="1.0" helpdir="" flags="control,hasdiskimage" />
</file>
<dependency>
<dependentAssembly>
<assemblyIdentity name="Assembly numero uno" version="1.1.0.0" type="win32" publicKeyToken="7XXXXXXXXXXXD" />
</dependentAssembly>
</dependency>
</assembly>
I want to add a new <dependency> section right after the </dependency> tag. The new <dependency> should look like this:
<dependency>
<dependentAssembly>
<assemblyIdentity name="Assembly number two" version="1.1.0.0" type="win32" publicKeyToken="7XXXXXXXXXXXD" />
</dependentAssembly>
</dependency>
How can I achieve this with Wix?
First of all, consider modifying the manifest at build time. If that's possible, it is much more preferable - always choose build-time complexity over install-time complexity.
It might make sense to leave this for install time only in case <dependency> element contents depends on the user input or the target system state. In this case you should use one of the WiX options to modify XML, either XmlFile #OleksandrPshenychnyy mentioned, or XmlConfig. I used the latter one more often, as it seems to be more flexible.
If you decide to go for modifying the manifest at install-time, you can still make your life a bit easier. Add the XML pattern to the manifest at build-time, and only modify the parts dependent on the user input or system state at install time. Let's say it is assemblyIdentity/version attribute. Then the WiX snippet might look like this:
<util:XmlConfig Id="VersionChange" ElementPath="assembly/dependency/dependentAssembly/assemblyIdentity[\[]#name='Assembly number two'[\]]" File="$(var.Manifest)" Name="version" Action="create" Node="value" On="install" PreserveModifiedDate="yes" Value="1.1.0.0" />
Note the square brackets escaping technique.
You can use WisUtilExtention library with XmlFile Element to perform some manipulations with XML file. For more details visit this link
I want to show a command on the toolbar based on the perspective. I have used core expressions to achieve this as below.
<extension point="org.eclipse.core.expressions.definitions">
<definition id="onValidationPerspective">
<with variable="activeWorkbenchWindow.activePerspective">
<equals value="com.sample.perspective1"/>
</with>
</definition>
</extension>
and I have used this in the command tag as below.
<command
commandId="com.sample.run.root"
icon="icons/run_exc.gif"
label="Reset Card"
style="pulldown">
<visibleWhen checkEnabled="false">
<reference
definitionId="onValidationPerspective">
</reference>
</visibleWhen>
</command>
The above code is working fine.
But I want to extend this for mutiple perspectives, i.e. I want to show the commands on the toolbar in 2 perspectives namely com.sample.perspective1 and com.sample.perspective2.
How can I achieve this using core expressions?
You can use the OR operation element:
<definition id="onValidationPerspective">
<or>
<with ...
<with ...
</or>
</definition>
<definition id="onValidationPerspective">
<with variable="activeWorkbenchWindow.activePerspective">
<or>
<equals value="com.sample.perspective1"/>
<equals value="com.sample.perspective2"/>
</or>
</with>
</definition>