Open sandboxFocusImprove this doc

LAMA0057: Metalama isn't enabled in the project

Severity Error
Reported by Metalama.Framework
Message Metalama is not enabled in this project.

Cause

When Metalama initializes the processing of a project, it first checks that Metalama is enabled in this project. It reports LAMA0057 and stops when one of the following conditions is true:

  • The compilation doesn't reference the Metalama.Framework assembly.
  • The compilation doesn't define the METALAMA preprocessor symbol, which the Metalama.Framework package normally adds to the DefineConstants property.
  • The MetalamaEnabled MSBuild property is set to False, or the MetalamaCompileTimeProject property is set to True.

During a normal build, Metalama skips the projects where MetalamaEnabled is False, and it reports a missing METALAMA symbol as LAMA0053. LAMA0057 therefore typically means that the Metalama.Framework package is installed, so the Metalama compiler runs, but the compilation doesn't reference the Metalama.Framework assembly. This happens, for instance, when the package reference excludes the compile assets with ExcludeAssets="compile".

This diagnostic depends on the package references and the MSBuild configuration of the project, so it can't be shown in an example.

Resolution

  • Reference the Metalama.Framework package with a plain PackageReference, without ExcludeAssets or IncludeAssets attributes that exclude the compile assets.
  • Make sure that MetalamaEnabled isn't set to False in the project or in a Directory.Build.props or Directory.Build.targets file, unless you don't want Metalama to process the project.
  • Make sure that the DefineConstants property isn't overwritten, so that it contains the METALAMA symbol.

See also