Teamcity System.IO.FileLoadException on UnitTests

0

In TeamCity my build configuration can restore and build my solution but when running tests it fails looking for Newtonsoft.Json version 6.0.0.0

I've turned logging onto diagnostic and can see that my redirects are working and version 11.0.0.2 is being used when building each project.

This project has two test classes, only one is failing (all tests in this class are failing as the constructor call new MoqMockingKernel() which is the line in the stack trace below).

Happy to provide more information as needed. It's an MSBuild 15.0 configuration.

I've tried adding Newtonsoft.Json to the test project directly but am still getting the same error below. These tests have worked previously but I just cannot seem to figure out what change has caused these tests to break.

Here is the stack trace from the test:

System.IO.FileLoadException : Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter..ctor() at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor() at System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters() at System.Web.Http.HttpConfiguration.DefaultFormatters(HttpConfiguration config) at System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes)
at System.Web.Http.GlobalConfiguration.<>c.b__11_0() at System.Lazy1.CreateValue()

--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Lazy1.get_Value() at Ninject.Web.WebApi.WebApiModule.Load() at Ninject.KernelBase.Load(IEnumerable1 m) at Ninject.Modules.ModuleLoader.LoadModules(IEnumerable`1 patterns) at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules) at Ninject.MockingKernel.MockingKernel..ctor() at Ninject.MockingKernel.Moq.MoqMockingKernel..ctor() at XXX.YYY.Web.Administration.Test.Services.ImportExportConfigServiceTests..ctor(ITestOutputHelper output) in D:\TeamCity\buildAgent\work\d7229fa1accd239b\Source\Source\Web.Administration.UnitTests\Services\ImportExportConfigServiceTests.cs:line 30

c#
msbuild
teamcity
asked on Stack Overflow Aug 16, 2019 by berniefitz

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0