I'm managing the build of a C# project using NuGet to obtain Common.Logging.Log4Net. Unit tests all pass with no errors when run from Visual Studio 2010, but when I run from the command line using MSTest (and therefore when TeamCity does the same), I get failures when the unit test hist a class that does this:
private static readonly ILog Log = LogManager.GetCurrentClassLogger();
and the error is:
Test method MyProject.Tests.Unit.BusinessDateBuilderTest.CreateElementalTest threw exception: System.TypeInitializationException: The type initializer for 'MyProject.Common.Library' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MyProject.Common.Initialization.Impl.InitializationLoaderImpl' threw an exception. ---> Common.Logging.ConfigurationException: Failed obtaining configuration for Common.Logging from configuration section 'common/logging'. ---> System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for common/logging: Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net' (C:\Subversion\Project\MyProject.Tests.Unit\bin\Debug\TestResults\rac_DWM300619 2012-10- 30 11_58_34\Out\MyProject.Tests.Unit.dll.config line 168) ---> Common.Logging.ConfigurationException: Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net' ---> System.IO.FileNotFoundException: Could not load file or assembly 'Common.Logging.Log4net' or one of its dependencies. The system cannot find the file specified.
I'm using the following NuGet dependencies:
Common.Logging.2.1.1 (DLL version is 2.1.1.0) Common.Logging.Log4Net.2.0.1 (DLL version is 2.0.0.0) log4net.1.2.10 (DLL version is 1.2.10)
I have noticed that Common.Logging.Log4net.dll is not copied to the testresults output folder - is this the problem? If so, how do I resolve this?
Common.Logging.Log4net
assembly is copied to the directory where the test runs. – Steven