behaviorConfiguration 属性的 Web Config 转换不起作用
Web Config Transformation for behaviorConfiguration attribute not working
Web.config原
<service behaviorConfiguration="Test.DevelopmentPc.Environment.Behavior" name="Tks.Licensing.Service.ActivationServer">
<endpoint address="" name="httpEndpoint" binding="basicHttpBinding" bindingConfiguration="testBasicHttpBinding" contract="Tks.Licensing.Contracts.ServiceContract.IActivationService"/>
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange"/>
</service>
我想要的样子
<service behaviorConfiguration="__BehaviorConfiguration__" name="Tks.Licensing.Service.ActivationServer">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding" name="httpEndpoint" contract="Tks.Licensing.Contracts.ServiceContract.IActivationService">
<identity>
<dns value="__ServerIdentity__"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" />
</service>
这是我已经尝试过的:
<service behaviorConfiguration="__BehaviorConfiguration__" name="Tks.Licensing.Service.ActivationServer" xdt:Transform="SetAttributes(behaviorConfiguration)" xdt:Locator="Match(name)">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding" name="httpEndpoint" contract="Tks.Licensing.Contracts.ServiceContract.IActivationService">
<identity xdt:Trasform="Insert">
<dns value="__ServerIdentity__"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" />
</service>
原来的网络配置根本没有改变。
原始网络配置中有几个不同名称的服务块。
我不允许对原始配置文件进行任何更改。有没有办法在不触及原始文件的情况下做到这一点?
我通过替换整个 "services" 元素让它工作。
<services xdt:Transform="Replace">
<service behaviorConfiguration="__BehaviorConfiguration__" name="Tks.Licensing.Service.ActivationServer">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding" name="httpEndpoint" contract="Tks.Licensing.Contracts.ServiceContract.IActivationService">
<identity>
<dns value="__ServerIdentity__"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" />
</service></services>
Web.config原
<service behaviorConfiguration="Test.DevelopmentPc.Environment.Behavior" name="Tks.Licensing.Service.ActivationServer">
<endpoint address="" name="httpEndpoint" binding="basicHttpBinding" bindingConfiguration="testBasicHttpBinding" contract="Tks.Licensing.Contracts.ServiceContract.IActivationService"/>
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange"/>
</service>
我想要的样子
<service behaviorConfiguration="__BehaviorConfiguration__" name="Tks.Licensing.Service.ActivationServer">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding" name="httpEndpoint" contract="Tks.Licensing.Contracts.ServiceContract.IActivationService">
<identity>
<dns value="__ServerIdentity__"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" />
</service>
这是我已经尝试过的:
<service behaviorConfiguration="__BehaviorConfiguration__" name="Tks.Licensing.Service.ActivationServer" xdt:Transform="SetAttributes(behaviorConfiguration)" xdt:Locator="Match(name)">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding" name="httpEndpoint" contract="Tks.Licensing.Contracts.ServiceContract.IActivationService">
<identity xdt:Trasform="Insert">
<dns value="__ServerIdentity__"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" />
</service>
原来的网络配置根本没有改变。
原始网络配置中有几个不同名称的服务块。 我不允许对原始配置文件进行任何更改。有没有办法在不触及原始文件的情况下做到这一点?
我通过替换整个 "services" 元素让它工作。
<services xdt:Transform="Replace">
<service behaviorConfiguration="__BehaviorConfiguration__" name="Tks.Licensing.Service.ActivationServer">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding" name="httpEndpoint" contract="Tks.Licensing.Contracts.ServiceContract.IActivationService">
<identity>
<dns value="__ServerIdentity__"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" />
</service></services>