Open sandboxFocusImprove this doc

LAMA0081: Projects of the same solution use different versions of Metalama

Severity Warning
Reported by Metalama.Framework
Message The project reference '<AssemblyIdentity>' has been compiled with Metalama <ReferenceVersion>, but the current project uses Metalama <CurrentVersion>. Using several versions of Metalama in the same solution is not recommended: it makes the build and the IDE slower, and it exposes you to compatibility issues. Align the version of Metalama across the projects of the solution.

Cause

When a project contains compile-time code, such as aspects or fabrics, Metalama embeds this code in the compiled assembly, together with the version of Metalama that compiled it. When another project references this assembly, Metalama reads the embedded code and compares its version with the version of Metalama that compiles the current project.

Metalama reports LAMA0081 when the two versions are different and the reference comes from a ProjectReference, that is, from another project of the same solution. In the message, <AssemblyIdentity> is the identity of the referenced assembly, <ReferenceVersion> is the version of Metalama that compiled it, and <CurrentVersion> is the version of Metalama used by the current project.

The build still works: Metalama reads the compile-time code of the referenced project and applies its aspects, whatever version produced it. However, the build and the IDE are slower, and you're exposed to compatibility issues between the versions.

Metalama doesn't report this warning in the following situations:

  • The reference is a NuGet package or a file reference. Consuming a package built with another version of Metalama is normal and supported.
  • The referenced project was compiled with a version of Metalama that the IDE can't load at all. In this case, Metalama reports the more specific warning LAMA0078 instead.

This diagnostic depends on the package versions used by several projects of a solution, so it can't be shown in an example.

Resolution

Use the same version of the Metalama packages in all projects of the solution:

  1. Find the projects that reference a different version. The message gives the name of the referenced project and both versions.
  2. Update the Metalama.Framework package, and any other Metalama.* package, to the same version in all projects. To keep the versions aligned in the future, define them in a single place, for instance with central package management in a Directory.Packages.props file at the root of the repository.
  3. Rebuild the solution, so that the referenced projects are compiled again with the new version.

If you have a good reason to keep several versions temporarily, you can suppress the warning by adding LAMA0081 to the NoWarn property of the referencing project.

See also