This project has moved and is read-only. For the latest updates, please go here.


TFS Test Build breaks with AutoMapper Exception


I have created a test cases for my application. All the test works fine when i run them locally. When i set up a build to run all the test every morning in TFS, i get this below error.

Error Message looks like this.

Class Initialization method RightsLine.Test.MockTest.CRUDCharacteristicTemplateTest.Setup threw exception. AutoMapper.AutoMapperConfigurationException: AutoMapper.AutoMapperConfigurationException:
The following property on System.Int32 cannot be mapped: <PROPERTY>
Add a custom mapping expression, ignore, add a custom resolver, or modify the destination type System.Int32.
Mapping to property <PROPERTY> from System.Byte to System.Int32
Mapping from type <CLASS_A> to <CLASS_B>
Exception of type 'AutoMapper.AutoMapperConfigurationException' was thrown..enter code here
Error Stack Trace looks like this.

AutoMapper.ConfigurationStore.DryRunTypeMap(ICollection1 typeMapsChecked, ResolutionContext context)
1 typeMapsChecked, ResolutionContext context)
AutoMapper.ConfigurationStore.AssertConfigurationIsValid(IEnumerable`1 typeMaps)
Why this DryRunTypeMap is throwing error when it runs the test build but not when i do it from local. Any help would be appreciated.

Closed Jul 30, 2015 at 2:04 PM by jbogard
The project has moved to GitHub.


Inzenet wrote Nov 5, 2014 at 9:51 AM


same problem here (on TeamCity).
have you found a solution ?



vcpatel wrote Nov 6, 2014 at 5:52 PM

Nope, haven't found a solution.

Inzenet wrote Nov 6, 2014 at 7:32 PM

We have one (thanks to my collegue Geoffrey for finding it)

If you have a unit test that fails because of AutoMapper’s AssertConfigurationIsValid in TeamCity (on the build step that uses MSTest) but doesn’t fail in Visual Studio Test Runner :
  • Make sure the AutoMapper nugget package is installer on the test project
  • Add this attribute on the TestClass : [DeploymentItem("AutoMapper.Net4.dll")]
here you are :) (hope this work for you)

vcpatel wrote Nov 6, 2014 at 8:17 PM

This does not fix for TFS Build.

wrote Jul 30, 2015 at 2:04 PM