MetalamaConceptual documentationCreating aspectsDistributing projects that use aspects
Open sandboxFocusImprove this doc

Distributing projects that use aspects

When your project employs aspects, it is essential to consider whether the projects that reference your project will also need to utilize aspects due to 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 due to one of the following reasons:

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

If this is the case, you don't 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 due to your project, you can prevent Metalama.Framework from flowing to its consumers by setting the PrivateAssets="all" property of the PackageReference.

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

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

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