WiX 安装程序:当 web.config 在其初始 msi 中设置为 NeverOverwrite=yes 时,我们可以使用补丁在 web.config 中添加新元素吗 [英] WiX installer: can we add a new element in web.config using a patch when it is set to NeverOverwrite=yes in its initial msi
问题描述
我正在开发一个网络应用程序.Web.config 文件在其初始安装中设置为 NeverOverwrite (=yes).现在我需要添加如下所示的 DBproviderfactories.我可以在 patch.msp 中使用 XmlFile 添加整个块吗?我不想编写自定义操作.我只需要在 web.config 中添加这个块.感谢这里的任何建议.
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>
推荐答案
下面是它的要点 - 请使用上面的示例进行测试.下面的标记仅用于说明.
Below is the gist of it - please use the sample above for testing. The markup below is just for illustration.
将 XML 文件设置为永久和永不覆盖.
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> </Directory>
链接:
这篇关于WiX 安装程序:当 web.config 在其初始 msi 中设置为 NeverOverwrite=yes 时,我们可以使用补丁在 web.config 中添加新元素吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!