我试图在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。