问题
I am working on a web application. the Web.config file is set to NeverOverwrite (=yes) in its initial installation. Now i need to add DBproviderfactories like below. Can i add this entire block using XmlFile in a patch.msp? I do not want to write a custom action. All I need is to add this block in the web.config. Any suggestion here is appreciated.
<system.data>
<DbProviderFactories>
<!-- Remove in case this is already defined in machine.config -->
<remove invariant="Oracle.ManagedDataAccess.Client" />
<add name="Oracle Data Provider for .NET" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
回答1:
Sample: Maybe try this: https://github.com/glytzhkof/all/blob/master/WiXUpdateXmlFile.zip
- Below is the gist of it - please use the sample above for testing. The markup below is just for illustration.
- Set the XML file both permanent and never overwrite.
- See inline instructions in the sample above for testing.
Check what happens on uninstall - this markup will remove the entries it added.
<!-- Set app.config permanent and never overwrite to yes --> <Component Feature="ProductFeature" NeverOverwrite="yes" Permanent="yes"> <File Source="app.config" /> </Component> <!-- The XML update --> <!-- Use a NEW GUID here, do not go live with this one --> <Component Id="XmlFileUpdate" Guid="{00000000-0000-0000-0000-7405EED51B57}" Feature='ProductFeature'> <!--Create New Element--> <util:XmlFile Id='XmlSettings1' File='[INSTALLFOLDER]app.config' Action='createElement' Name='MyConfig' ElementPath='//configuration' Sequence='1' /> <!--Set New Value--> <util:XmlFile Id='XmlSettings2' File='[INSTALLFOLDER]app.config' Action='setValue' Name='newVersion' Value='6.6.8' ElementPath='//configuration/MyConfig' Sequence='2' /> <!--Set New Value--> <util:XmlFile Id='XmlSettings3' File='[INSTALLFOLDER]app.config' Action='setValue' Name='Server' Value='Pusevov' ElementPath='//configuration/MyConfig' Sequence='3' /> <!--Update Existing Value, Existing Element--> <util:XmlFile Id='XmlSettings4' File='[INSTALLFOLDER]app.config' Action='setValue' Name='newVersion' Value='7.7.7' ElementPath='//configuration/ExistingConfig/bindingRedirect' Sequence='4' /> <CreateFolder /> </Component> </Directory>
Link:
- Added new application setting to app.config but MSI won't install it (doesn't overwrite)
来源:https://stackoverflow.com/questions/59823447/wix-installer-can-we-add-a-new-element-in-web-config-using-a-patch-when-it-is-s