I am having some problems with a single test project on our build server. Some of the tests in the project uses AutoFixture with AutoMoq.
Since AutoMoq uses an older Moq version than the one we use otherwise, we have a redirection in the app.config (made by the AutoMoq NuGet script I assume):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1409.1722" newVersion="4.2.1409.1722" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Ploeh.AutoFixture" publicKeyToken="b24654c590009d4f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.20.2.0" newVersion="3.20.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
The tests run without a problem on the developer machines, but one project (among many that uses AutoFixture, AutoMoq and Moq) throws this at me when run with TeamCitys NUnit runner:
Test(s) failed. System.IO.FileLoadException : Could not load file or assembly 'Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Ploeh.AutoFixture.AutoMoq.MockPostprocessor.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.CustomizationNode.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.BehaviorRoot.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Fixture.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.SpecimenContext.Resolve(Object request)
at Ploeh.AutoFixture.SpecimenFactory.Create[T](ISpecimenContext context, T seed)
at Ploeh.AutoFixture.SpecimenFactory.Create[T](ISpecimenContext context)
Why is the Moq reference to (4.0.10827.0 apparently) not redirected to 4.2.1409.1722?
I have checked the build-server working directory and the app.config and dlls looks fine.