| Severity | Error |
| Reported by | Metalama.Framework |
| Message | The assembly '<AssemblyName>' is required by the compile-time code of a referenced assembly, but it cannot be found among the references of the current project. Add a reference to '<AssemblyName>'. |
Cause
When a project contains compile-time code, such as aspects or fabrics, Metalama embeds this code in the compiled assembly, together with the list of the other assemblies whose compile-time code it uses. When your project references this assembly, Metalama loads its compile-time code and, recursively, the compile-time code of the assemblies it depends on. Metalama looks for these assemblies among the references of your project.
Metalama reports LAMA0027 when one of these assemblies, <AssemblyName> in the message, isn't among the references of the current project. Metalama then can't load the compile-time code of the referencing assembly, and the build fails. This can happen in the following situations:
- A package or project that contains aspects depends on another assembly with compile-time code, but this dependency doesn't flow to your project, for instance because it's referenced with
PrivateAssets="all". - You reference an assembly with compile-time code directly as a file, without the assemblies it depends on.
This diagnostic depends on the references and the configuration of several projects, so it can't be shown in an example.
Resolution
- Identify the missing assembly from the message.
- Add a reference to this assembly to the project that reports the error, as a package reference, a project reference, or a file reference.
- If you're the author of the library that contains the aspects, make sure that its dependencies with compile-time code flow to the consuming projects. Don't mark them with
PrivateAssets="all".