Metalama//Conceptual documentation/Creating aspects/Distributing projects that use aspects
Open sandboxFocus

Distributing projects that use aspects

When your project uses aspects, you must consider whether the projects that reference your project will also need to use aspects just because of this reference.

Flowing the use of aspects

Your project may flow the necessity to use aspects and the aspect framework to consumers of your project for one of the following reasons:

  • Your project exposes public aspects that the other projects can use.
  • Your project has non-sealed, public classes with inheritable aspects.
  • Your project has public classes that have reference validators.
  • Your project contains a transitive project fabric or references a project that contains one.

If this is the case, you do not need to take any action. Your package reference to Metalama.Framework will flow to the consumers of your project.

Preventing the transitive use of aspects

If consumers of your project will not need to use aspects just because of your project, you can prevent Metalama.Framework from flowing to its consumers by setting the PrivateAssets="all" property of the PackageReference.

Additionally, you need to include the Metalama.Framework.Redist package, which is the only package that needs to flow to consumers.

This is achieved by the following code snippet in your .csproj file:

<ItemGroup>
  <PackageReference Include="Metalama.Framework" Version="CHANGE ME" PrivateAssets="all"/>
  <PackageReference Include="Metalama.Framework.Redist" Version="CHANGE ME"/>
</ItemGroup>