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
- .NET CLI
- Package Manager
<PackageReference Include="Riok.Mapperly" Version="4.1.1" ExcludeAssets="runtime" PrivateAssets="all" />
dotnet add package Riok.Mapperly
To remove the runtime dependency of Mapperly add
ExcludeAssets="runtime"
and PrivateAssets="all"
to the resulting PackageReference
.
Install-Package Riok.Mapperly
To remove the runtime dependency of Mapperly add
ExcludeAssets="runtime"
and PrivateAssets="all"
to the resulting PackageReference
.
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>
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
.
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>