2010-10-20 40 views
2

我正在编辑我的web.release.config文件以进行生产。我想在发布后更改web.config文件。 我发现如何通过正确使用web.release.config文件来更改web.config,但不适用于此特定组件。web.release.config更改动态webservice url

动态webservice的URL必须更改。

在web.config:

<applicationSettings> 
    <FooService.Properties.Settings>  
     <setting name="FooService_Student" serializeAs="String"> 
      <value>http://testwebservices.foo.bar.nl/Student.asmx</value> 
     </setting> 
     <setting name="FooService_User" serializeAs="String"> 
      <value>http://testwebservices.foo.bar.nl/User.asmx</value> 
     </setting> 
    </FooService.Properties.Settings> 
</applicationSettings> 

现在,我该如何改变在这两种环境的<value>?我尝试了以下方法,但没有解决:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <applicationSettings> 
     <FooService.Properties.Settings>  
      <setting name="FooService_Student" serializeAs="String" xdt:Transform="Replace"> 
       <value>http://webservices.foo.bar.nl/Student.asmx</value> 
      </setting> 
      <setting name="FooService_User" serializeAs="String" xdt:Transform="Replace"> 
       <value>http://webservices.foo.bar.nl/User.asmx</value> 
      </setting> 
     </FooService.Properties.Settings> 
    </applicationSettings> 
</configuration> 

任何有关此事的经验?

谢谢!

回答

1

如何添加xdt:Locator="Match(name)",这可能是您需要找到要替换的确切节点。

+0

这应该与上述答案被组合以提供该问题的更一般(和正确的)的方法。谢谢分享,先生。 – tfrascaroli 2015-12-10 08:24:56

2

xdt:Transform="Replace"添加到applicationSettings标签。

<applicationSettings xdt:Transform="Replace"> 
<FooService.Properties.Settings>  
    <setting name="FooService_Student" serializeAs="String"> 
     <value>http://webservices.foo.bar.nl/Student.asmx</value> 
    </setting> 
    <setting name="FooService_User" serializeAs="String"> 
     <value>http://webservices.foo.bar.nl/User.asmx</value> 
    </setting> 
</FooService.Properties.Settings>