我有一个使用Wix 3.5构建的MSI安装程序,我正在尝试使用它在安装期间编辑web.config xml文件:
<Component Id="EditWebConfigToUseCertificate" Guid="xxx">
<util:XmlConfig Id="configureX509Value"
File="[WebServiceFolder]web.config"
ElementPath="configuration/system.serviceModel/behaviors/serviceBehaviors/behavior[\[]1[\]]/serviceCredentials/serviceCertificate"
Name="x509FindType"
Value="FindBySubjectName"
Sequence="1" />
</Component>
我无法使其工作,我无法让它更改文件的任何属性。 MSI安装正常,但web.config永远不会更改。我检查了文件路径(硬编码),XPath也是正确的。为什么不修改文件?安装日志显示没有错误。
这是我的web.config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E31" />
</assemblies>
</compilation>
<!-- do not use asp.net authentication -->
<authentication mode="None" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<clear />
<behavior name="AuthenticationServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<!-- service credentials -->
<serviceCredentials>
<serviceCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySerialNumber" findValue="00 91 d9 2e 07 82 d8 99 c0" />
</serviceCredentials>
</behavior>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<!-- service credentials -->
<serviceCredentials>
<serviceCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySerialNumber" findValue="00 91 d9 2e 07 82 d8 99 c0" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</configuration>
答案 0 :(得分:0)
我最终成功了。对我有用的代码就是:
<util:XmlConfig Id='configureX509Value' File='[WebServicesFolder]web.config'
Action='create'
Name='findValue'
Node='value'
ElementPath="//configuration/system.serviceModel/behaviors/serviceBehaviors/behavior[\[]0[\]]/serviceCredentials/serviceCertificate"
Value="[CERT_SERIAL_NUMBER]"
On='install'
PreserveModifiedDate='yes'
VerifyPath="//configuration/system.serviceModel/behaviors/serviceBehaviors/behavior[\[]0[\]]/serviceCredentials/serviceCertificate" />