BT

AutoMapper and Working with Cross-Platform Assemblies

| by Jonathan Allen Follow 636 Followers on Mar 11, 2015. Estimated reading time: 1 minute |

With the creation of CoreCLR and the increasing popularity of Xamarin, it is becoming more and more important that .NET libraries are offered in a cross-platform fashion. Sometimes one can get away with using the PCL format, but more often than, cross-platform really means multiple platform builds.

Jimmy Bogard of AutoMapper fame ran into just this problem with Microsoft made a feature request for CoreCLR support for AutoMapper.

The traditional way to deal with multiple platform builds is to create a separate project file for each platform. One project would be the “master” and contain all of the source code. The other projects would use linked files to include just the files appropriate for the target platform.

This pattern doesn’t work with CoreCLR/vNext projects. Instead of picking individual files, this project type defaults to including all of the files via wildcards. Including all of the files in each project in turn requires heavy use of conditional compilation directives.

It should be noted that you don’t need vNext style projects to use wildcards. Though not exposed in the Visual Studio IDE, C# project files have always had the option to use wildcards instead of explicitly listing each file.

For more about cross-platform assemblies and Jimmy Bogard’s work on AutoMapper, check out his article titled Cross-Platform AutoMapper (again).

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT