我有一些看起来像这样的XML:
<?xml version="1.0" encoding="utf-8"?>
<XmlConfig instancetype="XmlConfig, Processing, Version=1.0.0.0, Culture=neutral">
<item>
<key>IsTestEnvironment</key>
<value>True</value>
<encrypted>False</encrypted>
</item>
<item>
<key>HlrFtpPutDir</key>
<value>C:\DevPath1</value>
<encrypted>False</encrypted>
</item>
<item>
<key>HlrFtpPutCopyDir</key>
<value>C:\DevPath2</value>
<encrypted>False</encrypted>
</item>
....
</Provisioning.Lib.Processing.XmlConfig>
Run Code Online (Sandbox Code Playgroud)
在TeamCity中,我有许多系统属性:
system.HlrFtpPutDir H:\ReleasePath1
system.HlrFtpPutCopyDir H:\ReleasePath2
Run Code Online (Sandbox Code Playgroud)
我可以用什么样的MsBuild魔法将这些值推送到我的XML文件中?总共有20个左右的项目.
我在VS2010中有一个Azure项目(Azure 1.3).有2个webroles,一个网页项目和一个WCF项目.在调试模式中,我希望Web项目使用web.config进行DEV环境,并且在发布web.config时必须使用PROD.
做这个的最好方式是什么 ?
目前,在使用带有转换XSLT的Web.Debug.config时,我遇到了问题.它似乎不适用于Azure ....
我想使用新的VS2010 web.config转换功能来更改web.config文件中nhibernate配置中的连接字符串.相关的代码片段是这样的:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
<property name="connection.connection_string">(test connection string)</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
...
Run Code Online (Sandbox Code Playgroud)
我没有成功地尝试了以下转换:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>
<property name="connection.connection_string" xdt:Transform="Replace">(production connection string)</property>
</session-factory>
</hibernate-configuration>
</configuration>
Run Code Online (Sandbox Code Playgroud)
问题似乎是在nhibernate-configuration元素的xmlns属性中.
在部署期间,用(生产连接字符串)替换(测试连接字符串)的正确转换应该是什么?
我正在开发云应用程序.当我在我的计算机上测试应用程序时,我希望在ServiceConfiguration.cscfg中将我的连接字符串设置如下:
<Setting name="DataConnectionString" value="UseDevelopmentStorage=true" />
Run Code Online (Sandbox Code Playgroud)
当我发布到云时,我需要将其设置如下:
<Setting name="DataConnectionString" value="DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=yyy" />
Run Code Online (Sandbox Code Playgroud)
我一直在从一个环境转到另一个环境,并不断更改DataConnectionString.
有没有办法让我自动化?我环顾四周,看不到任何例子,但我确信其他一些人和我有同样的问题.
谢谢,
南希