I'm trying to create an installer that will deploy a .NET Managed data provider. In order for the data provider to appear as a provider in application drop-downs, I have to add the provider in the machine.config's section:
我正在尝试创建一个将部署.NET托管数据提供程序的安装程序。为了使数据提供程序在应用程序下拉列表中显示为提供程序,我必须在machine.config的部分中添加提供程序:
<system.data>
<DbProviderFactories>
<add name="My Data Provider"
invariant="Sample.MyDataProvider"
description="My Data Provider"
type="Eli.Sample.MyDataProvider, Sample.MyDataProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b9d34470b87a97f"
/>
</DbProviderFactories>
</system.data>
How do I do this? Just a pointer would be fine. Thanks.
我该怎么做呢?只需一个指针即可。谢谢。
2 个解决方案
#1
If your using Wix you can use the XmlConfig element.
如果你使用Wix,你可以使用XmlConfig元素。
<util:XmlConfig
Id="Machine_Config_Xml_Root"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
Action="create"
On="install"
ElementPath="//configuration/system.data/DbProviderFactories"
Name="add"
Node="element"
Sequence="1">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_2"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
ElementPath="Machine_Config_Xml_Root"
Name="name"
Value="My Data Provider"
Sequence="2">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_2"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
ElementPath="Machine_Config_Xml_Root"
Name="invariant"
Value="Sample.MyDataProvider"
Sequence="2">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_2"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
ElementPath="Machine_Config_Xml_Root"
Name="description"
Value="My Data Provider"
Sequence="2">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_2"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
ElementPath="Machine_Config_Xml_Root"
Name="type"
Value="Eli.Sample.MyDataProvider, Sample.MyDataProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b9d34470b87a97f"
Sequence="2">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_Uninstall_1"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
Action="delete"
On="uninstall"
ElementPath="//configuration/system.data/DbProviderFactories/add[\[]@invariant='Sample.MyDataProvider'[\]]"
Sequence="1">
</util:XmlConfig>
#2
You need to create a custom installer action and add it to your MSI to do this (I'm assuming you're using a Visual Studio setup project to do this).
您需要创建自定义安装程序操作并将其添加到MSI才能执行此操作(我假设您正在使用Visual Studio安装程序来执行此操作)。
#1
If your using Wix you can use the XmlConfig element.
如果你使用Wix,你可以使用XmlConfig元素。
<util:XmlConfig
Id="Machine_Config_Xml_Root"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
Action="create"
On="install"
ElementPath="//configuration/system.data/DbProviderFactories"
Name="add"
Node="element"
Sequence="1">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_2"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
ElementPath="Machine_Config_Xml_Root"
Name="name"
Value="My Data Provider"
Sequence="2">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_2"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
ElementPath="Machine_Config_Xml_Root"
Name="invariant"
Value="Sample.MyDataProvider"
Sequence="2">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_2"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
ElementPath="Machine_Config_Xml_Root"
Name="description"
Value="My Data Provider"
Sequence="2">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_2"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
ElementPath="Machine_Config_Xml_Root"
Name="type"
Value="Eli.Sample.MyDataProvider, Sample.MyDataProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b9d34470b87a97f"
Sequence="2">
</util:XmlConfig>
<util:XmlConfig
Id="Machine_Config_Xml_Uninstall_1"
File="[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.Config"
Action="delete"
On="uninstall"
ElementPath="//configuration/system.data/DbProviderFactories/add[\[]@invariant='Sample.MyDataProvider'[\]]"
Sequence="1">
</util:XmlConfig>
#2
You need to create a custom installer action and add it to your MSI to do this (I'm assuming you're using a Visual Studio setup project to do this).
您需要创建自定义安装程序操作并将其添加到MSI才能执行此操作(我假设您正在使用Visual Studio安装程序来执行此操作)。