相关疑难解决方法(0)

使用configSource转换包含的配置文件

这个问题有点像两个人.在VS2015中,我的MVC项目有多种不同的构建配置,Test,UAT,Live等.web.config我可以直接右键单击它并选择Add Config Transform为每个构建配置创建转换文件.

如果我有一个外部配置文件,例如Log4Net.config如何配置它以具有相关的转换web.config?这是通过编辑project.csproj文件手动完成的吗?

其次,我有一个web.config文件:

<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, Log4net" />
    </configSections>

    ...

    <log4net configSource="Log4Net.config" />
</configuration>
Run Code Online (Sandbox Code Playgroud)

当我构建项目时,会web.config自动通过project.csproj文件中的以下AfterBuild目标进行转换:

<Target Name="AfterBuild">
    <TransformXml Source="Web.config"
            Transform="Web.$(Configuration).config"
            Destination="$(OutputPath)\$(AssemblyName).config" />
</Target>
Run Code Online (Sandbox Code Playgroud)

如何Log4Net.config使用相同的配置转换转换包含的文件?我意识到我可以将另一个TransformXml放入AfterBuild目标中,但是这是进行此转换的正确方法,还是我错过了什么?

c# asp.net-mvc web-config visual-studio web-config-transform

7
推荐指数
1
解决办法
2303
查看次数