Error de configuración de Log4Net que hace que MSBuild falle

I'm trying to set up a CI environment at a new client site using Team City and MSbuild and the MS build community extensions. Compiling the code seems to work fine. However, when I run my unit tests I get the following error coming from the NUnit task:

log4net : error XmlConfigurator: Failed to find configuration section 'log4net' in the   application's .config file.

I've identified the two test projects that are causing this issue. However, I've ran the tests directly from nunit-console, and the resharper nunit test runner and though I see the warning the tests don't fail. I don't want to do anything with the Log4net configuration file or the assembly.cs in any project. All I want to do is make the MSBuild script behave like Visual Studio which doesn't consider the log4net error as a failure.

Here's the build file

    <?xml version="1.0" encoding="utf-8"?>
    <Project xmlns="" ToolsVersion="4.0"      DefaultTargets="Compile">
    <Import Project=".\MSBuild.Community.Tasks.Targets"/>

        <Configuration Condition="'$(Configuration)' == ''"> Debug</Configuration>    

    <BuildArtifacts Include=".\build_artifacts\"/>
    <SolutionFile Include ="..\Core.Services.sln"/>
    <NUnitPath Include="..\Packages\NUnit.\tools"/>          

  <Target Name="Clean">
    <RemoveDir Directories="@(BuildArtifacts)"/>

    <Target Name="Init" DependsOnTargets="Clean">
    <MakeDir Directories="@(BuildArtifacts)"/>

    <Target Name="Compile"  DependsOnTargets="Init">    

    <Target Name="DevelopmentBuild" DependsOnTargets="Compile">
         <Message Text="Running Unit Tests from %(BuildArtifacts.FullPath)...."      ContinueOnError="true"></Message>

    <CreateItem Include="%(BuildArtifacts.FullPath)*.Tests.dll">
    <Output TaskParameter="Include" ItemName="TestAssembly" />
    <NUnit Assemblies="@(TestAssembly)"

preguntado el 01 de febrero de 12 a las 14:02

Checked this questions before but I think the issues are slightly different. can you check my edit and see if the question makes sense? -

I would check the NUnit test project. Does the build run from a location it can find its app.config or log4net files? -

There's no app.config in the NUnit project. Adding one fixes the issue but I'm trying to not have the UT dependent on a App.config file. I rather change the build script to ignore the Log4Net error like nunit-console and resharper do. -

Then you need share the part of the build script you want to change. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.