2

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="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"      DefaultTargets="Compile">
    <Import Project=".\MSBuild.Community.Tasks.Targets"/>

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

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

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

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

    <Target Name="Compile"  DependsOnTargets="Init">    
    <MSBuild            
    Projects="@(SolutionFile)"            
    Targets="Rebuild"
    Properties="OutDir=%(BuildArtifacts.FullPath)">      
    </MSBuild>    
    </Target>

    <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" />
    </CreateItem>
    <NUnit Assemblies="@(TestAssembly)"
        ToolPath="@(NUnitPath)\"
        ContinueOnError="false"           
        OutputXmlFile="%(BuildArtifacts.FullPath)test-results.xml"
        DisableShadowCopy="true"/>    
      </Target>  
    </Project>
dalcantara
  • 1,613
  • 2
  • 21
  • 35
  • Does it look like this? http://stackoverflow.com/questions/1930083/log4net-configuration-exception – KMoraz Feb 01 '12 at 14:40
  • Checked this questions before but I think the issues are slightly different. can you check my edit and see if the question makes sense? – dalcantara Feb 01 '12 at 16:59
  • I would check the NUnit test project. Does the build run from a location it can find its app.config or log4net files? – KMoraz Feb 01 '12 at 18:39
  • 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. – dalcantara Feb 01 '12 at 20:53
  • Then you need share the part of the build script you want to change. – KMoraz Feb 01 '12 at 21:41
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/7264/discussion-between-buzzer-and-kmoraz) – dalcantara Feb 02 '12 at 03:49

0 Answers0