English 中文(简体)
在VS-2010年创建环境组合文件
原标题:Creating Environment-specific configuration files in VS-2010

我试图在2010年视觉演播室中建立具体的环境配置,并且能够把转变推到任何其他时候的App.config。 我的设想的一个例子是:

  • Added a configuration file in my project (e.g. ConfigsLog4Net.config). The file is set to "Content" and "Copy Always"
<log4net>
  <root>
    <appender-ref ref="EventLogAppender" />
    <level value="DEBUG" />
  </root>
  <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
  ...
  </appender>
</log4net>
  • Added a transformation configuration file (e.g. ConfigsLog4Net.Release.config)
<log4net xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <root>
    <level value="WARN" xdt:Transform="SetAttributes" xdt:Locator="XPath(log4net/root/level[@value!= WARN ])" />
  </root>
</log4net>
  • Modified the VS Project file to include the following target
<UsingTask TaskName="TransformXml" 
           AssemblyFile="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov10.0WebMicrosoft.Web.Publishing.Tasks.dll" />

<Target Name="AfterPublish" Condition="exists( ConfigsLog4Net.$(Configuration).config )">
  <TransformXml Source="ConfigsLog4Net.config" 
                Destination="$(OutputPath)ConfigsLog4Net.config" 
                Transform="ConfigsLog4Net.$(Configuration).config" />
</Target>

我在上诉案中遵循了类似的模式,而且该模式是行得通的,但似乎并不奏效。 我期望,当我做一个<<>Release的建筑时,应将标识水平定为WARN

问题回答

I m using XmlPreprocess tool for config files manipulation. It is using one mapping file for multiple environments. You can edit mapping file by Excel. It is very easy to use.

取代您的变革 承担Exec任务,使用XmlPreprocess工具。





相关问题
Enabling Ant Tools in a new Eclipse Galileo installation

I have recently installed Eclipse Galileo with the PHP Developers Tools. I plan to install the Flash Builder 4 Plug-in to do ActionScript development as well. I want to use Eclipse to both create an ...

Continuous Integration with Teamcity and Clearcase

Has anybody successfully integrated Clearcase with Teamcity (which advertises Clearcase support) to realize a productive continuous integration build environment on a decent size project?

热门标签