unoplatform/uno · error · InvalidOperationException

The configuration property must be provided

Error message

The configuration property must be provided

What it means

Thrown during XamlCodeGeneration constructor initialization when the MSBuild property 'Configuration' is null. The source generator reads this property via context.GetMSBuildPropertyValue("Configuration") and throws an InvalidOperationException if it is absent.

Source

Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs:191

		public XamlCodeGeneration(GeneratorExecutionContext context)
		{
			// To easily debug XAML code generation:
			// Add <UnoUISourceGeneratorDebuggerBreak>True</UnoUISourceGeneratorDebuggerBreak> to your project

			if (!Helpers.DesignTimeHelper.IsDesignTime(context)
				&& (context.GetMSBuildPropertyValue("UnoUISourceGeneratorDebuggerBreak")?.Equals("True", StringComparison.OrdinalIgnoreCase) ?? false))
			{
				Debugger.Launch();
			}

			_generatorContext = context;
			InitTelemetry(context);

			_metadataHelper = new RoslynMetadataHelper(context);

			_configuration = context.GetMSBuildPropertyValue("Configuration")
				?? throw new InvalidOperationException("The configuration property must be provided");

			_isDebug = string.Equals(_configuration, "Debug", StringComparison.OrdinalIgnoreCase);

			_projectFullPath = context.GetMSBuildPropertyValue("MSBuildProjectFullPath");
			_projectDirectory = Path.GetDirectoryName(_projectFullPath)
				?? throw new InvalidOperationException($"MSBuild property MSBuildProjectFullPath value {_projectFullPath} is not valid");

			var pageItems = GetWinUIItems("Page").Concat(GetWinUIItems("UnoPage"));
			var applicationDefinitionItems = GetWinUIItems("ApplicationDefinition").Concat(GetWinUIItems("UnoApplicationDefinition"));

			_xamlSources = pageItems
				.Except(applicationDefinitionItems, MSBuildItem.IdentityComparer)
				.Concat(applicationDefinitionItems)
				.Distinct(MSBuildItem.IdentityComparer)
				.Select(item => new XamlSource(item, GetSourceLink(item)))
				.ToArray();

			_excludeXamlNamespaces = context.GetMSBuildPropertyValue("ExcludeXamlNamespacesProperty");

View on GitHub (pinned to 0418340488)

Solutions

  1. Ensure the build is invoked through a standard MSBuild or dotnet build command that sets Configuration (e.g. dotnet build -c Debug).
  2. If invoking the generator programmatically, set Configuration in the generator's MSBuild property provider.
  3. Check that no custom .targets file is clearing or overriding Configuration to null.

Example fix

<!-- In a custom .targets or build script, ensure Configuration is set: -->
<PropertyGroup>
  <Configuration>Debug</Configuration>
</PropertyGroup>
Defensive patterns

Strategy: validation

Validate before calling

<!-- Ensure Configuration is set in build scripts -->
<Project>
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  </PropertyGroup>
</Project>
<!-- Or always pass -c/--configuration: dotnet build -c Debug -->

Prevention

When it happens

Trigger: The XAML source generator is invoked by a build host or tool that does not set the 'Configuration' MSBuild property — e.g. a custom Roslyn-based analysis tool, an IDE integration that bypasses MSBuild, or a misconfigured targets file.

Common situations: Building with a custom MSBuild script that does not set Configuration; running the generator in a unit test harness that does not provide MSBuild properties; a corrupted or partial .props/.targets chain that drops Configuration.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/cac296b62d4ef5db. Report an issue: GitHub.