I have unit tests that pass in the NUnit and Resharper GUI but don't work when Team City launches them

I have a TeamCity server configured to create multiple solutions, and then run unit tests on them using the NUnit Test Runner.

This works fine for several months; however, with our last build, I ran into the following error:

Failed to execute SetUp method. SetUp: System.IO.FileLoadException: Could not load file or assembly 'log4net, Version = 1.2.13.0, Culture = neutral, PublicKeyToken = 669e0ddf0bb1aa2a' or one of its dependencies. The installed assembly manifest definition does not match the Help assembly. (Exception from HRESULT: 0x80131040)

This only happens for one TestFixture, which contains 9 out of hundreds of tests throughout the system. All tests pass at startup using ReSharper or the NUnit GUI.

The Nuget package correctly references both the test project and the test project itself. There is no need to redirect the assembly because only one version of Log4Net has been installed.

Has anyone else had a similar problem that they solved or any ideas as to what could be the problem? Why it will work locally and not on the server, especially taking into account the same tests that were passed earlier.

The versions of NUnit on my local machine and on my TeamCity server are the same.

+5
source share
1 answer

I will simply answer my question if anyone else comes across this.

The problem is that the Log4Net build manifest was not packaged correctly, or at least different from what you might expect.

This is due to the version of the DLL version 1.2.13, but the version of the NuGet package is 2.0.3.

What we did was add a binding to the assembly, such as the following: fixed the problem:

<dependentAssembly> <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="2.0.3" /> </dependentAssembly> 

I have absolutely no idea why this was possible only for one project from ~ 60 that was built or why it worked in my environment for testing VS / ReSharper Nunit, but with an error for TeamCity!

+4
source

Source: https://habr.com/ru/post/1207788/


All Articles