1

we are developing an application in AnyCpu mode. The application uses a native library which we correctly resolve at runtime depending on the execution mode.

To compile we use one of both libraries as the interfaces do not change but we get the warning MSB3187 (which is right but do not apply here).

Is there a way to disable it? We have a policy to have clean builds without warnings that we would like to maintain.

Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207

1 Answers1

1

As MSDN statement for MSBuild Error MSB3187:

This warning is generated when the application's target platform (processor architecture) is set to neutral (MSIL) and the referenced assembly is not neutral, or if the application's architecture is not neutral and the dependency is neutral. Also, if both are not platform-neutral, then their architecture must match. In addition, application architecture and entry point assembly architecture must always match.

Since your application is compatible with "Any CPU" but you should have a dependency on a project or .dll assembly that is either x86 or x64. Visual Studio will give this waring.

To make the warning go away, you should make sure that the application's target platform (processor architecture) matches all referenced assemblies and the entry point assembly architecture.

Hope this could help you

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • The property removes the warning from VS but not from MSBuild compilation on the build machine :\ The other information is clear, at runtime we resolve the right version of the native dll and load it. – Ignacio Soler Garcia Mar 09 '17 at 14:47
  • @Ignacio Soler Garcia, since I could not reproduced the "MSB" error to verify that property, I will update my answer disable this part of the property until I can verify it. – Leo Liu Mar 10 '17 at 01:41