MetalamaConceptual documentationConfiguring and troubleshootingMSBuild properties and items
Open sandboxFocusImprove this doc

MSBuild properties and environment variables

Environment variables

Property Type Description
METALAMA_TEMP String The root path of Metalama temporary directory. The default value is the result of Path.GetTempPath().

MSBuild properties

Note that all environment variables are imported as MSBuild properties by default.

Property Type Description
MetalamaCompilerTransformerOrder Semicolon-separated list Specifies the execution order of transformers in the current project. Transformers are identified by their namespace-qualified type name but without the assembly name. This property is generally unimportant because the only transformer is typically Metalama.Framework.
MetalamaDebugTransformedCode Boolean Indicates that you want to debug the transformed code instead of the source code. The default value is False.
MetalamaEmitCompilerTransformedFiles Boolean Indicates that Metalama.Compiler should write the transformed code files to disk. The default is True if MetalamaDebugTransformedCode is enabled and False otherwise.
MetalamaCompilerTransformedFilesOutputPath Path Specifies the directory path where the transformed code files are written. The default is obj/$(Configuration)/metalama.
MetalamaDebugCompiler Boolean Specifies that you want to attach a debugger to the compiler process. The default value is False.
MetalamaLicense String Represents a Metalama license key or license server URL. Any license key or license server URL provided this way takes precedence over the license registered via the metalama global tool.
MetalamaEnabled Boolean When set to False, specifies that Metalama.Framework should not execute in this project, although the Metalama.Framework package is referenced in the project. It does not affect the Metalama.Compiler package.
MetalamaFormatOutput Boolean Indicates that the transformed code should be nicely formatted. The default value is True if MetalamaDebugTransformedCode is True and False otherwise. Formatting the transformed code has a performance overhead and should only be performed when the code is troubleshot or exported.
MetalamaFormatCompileTimeCode Boolean Indicates that the compile-time code should be nicely formatted. The default value is False. Formatting the compile-time code has a performance overhead and should only be performed when the code is troubleshot or exported.
MetalamaCompileTimeProject Boolean Indicates that the complete project is compile-time code. This property is set to True by the Metalama.Framework.Sdk package. Otherwise, the default value is False.
MetalamaDesignTimeEnabled Boolean Indicates that the real-time design-time experience is enabled. The default value is True, and it can be set to False to work around performance issues. When this property is set to False, refreshing the IntelliSense cache requires you to rebuild the project.
MetalamaRemoveCompileTimeOnlyCode Boolean Indicates that Metalama should replace compile-time-only code with throw new NotSupportedException() in produced assemblies. The default value is True because Metalama normally executes compile-time-only code from the compile-time sub-project embedded as a managed resource in the assembly. This property should be set to False in public assemblies referenced by a weaver-style project (using Metalama SDK) because Metalama SDK needs to execute compile-time-only code from the main assembly.
MetalamaCompileTimeTargetFrameworks Semicolon-separated list Specifies the list of target frameworks for which compile-time projects should be built. The default value is netstandard2.0;net6.0;net48. Override this property if you cannot install the required .NET targetting packs on the machine. netstandard2.0 is required.
MetalamaRestoreSources Semicolon-separated list Specifies the list of NuGet feeds used when restoring the compile-time project. The default value is
MetalamaCreateLamaDebugConfiguration Boolean Indicates that the LamaDebug build configuration should be automatically defined (see below). The default value is True.
MetalamaTemplateLanguageVersion String Specifies the C# language version (e.g. 10.0) that's used by templates. Any syntax from higher C# versions is not allowed in template bodies. Such templates can then be used in projects that use this C# version.
MetalamaConcurrentBuildEnabled Boolean Specifies that Metalama can parallelize the work on several cores. The default value is True.
MetalamaRoslynIsCompileTimeOnly Boolean Indicates that types from the Microsoft.CodeAnalysis namespaces are considered compile-time-only. The default value is True. Set it to False if your project uses Roslyn in run-time code.

MSBuild items

Item Description
MetalamaTransformedCodeAnalyzer Represents a list of analyzers that must execute on the transformed code instead of the source code. Items can be set to a namespace or a full type name.
MetalamaCompileTimePackage Represents a list of packages accessible from the compile-time code. These packages must explicitly target .NET Standard 2.0 and be included in the project as a ProjectReference. By default, only the .NET Standard 2.0 API and the Metalama API are available to compile-time code.

MSBuild build configurations

When you import the Metalama.Framework, a new build configuration named LamaDebug is defined unless you explicitly set the MetalamaCreateLamaDebugConfiguration property to False.

The LamaDebug configuration assigns the following properties:

<PropertyGroup Condition="'$(Configuration)'=='LamaDebug'">