Skip to main content

Installation

Add the NuGet Package to your project

All you need to do, to install Mapperly is to add a NuGet reference pointing to the package Riok.Mapperly.

<PackageReference Include="Riok.Mapperly" Version="4.1.1" ExcludeAssets="runtime" PrivateAssets="all" />

Preserving the attributes at runtime

Mapperly removes the attribute references at compile time by default (they have the ConditionalAttribute). If you want to preserve the attribute references at runtime you can set the MSBuild variable MapperlyAbstractionsScope to runtime.

<PropertyGroup>
<MapperlyAbstractionsScope>runtime</MapperlyAbstractionsScope>
</PropertyGroup>
info

When preserving the attribute usages, the Mapperly package reference needs to include the runtime assets.
Make sure ExcludeAssets on the PackageReference does not include runtime.

info

MapperlyAbstractionsScope only works in projects referencing Riok.Mapperly directly. Alternatively you can set a constant MAPPERLY_ABSTRACTIONS_SCOPE_RUNTIME:

<PropertyGroup>
<DefineConstants>$(DefineConstants);MAPPERLY_ABSTRACTIONS_SCOPE_RUNTIME</DefineConstants>
</PropertyGroup>