unoplatform/uno · error · InvalidOperationException
The configuration property must be provided
Error message
The configuration property must be provided
What it means
The NativeCtors generator reads the MSBuild 'Configuration' property (Debug/Release) to decide hot-reload codegen. GetMSBuildPropertyValue returns null when the property is unset, which the generator treats as invalid and throws InvalidOperationException. MSBuild normally defines Configuration, so a null usually indicates the generator ran outside a normal build.
Source
Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/NativeCtor/NativeCtorsGenerator.cs:55
private readonly INamedTypeSymbol? _jniHandleOwnershipSymbol;
private readonly INamedTypeSymbol?[] _javaCtorParams;
private readonly string _configuration;
private readonly bool _isDebug;
private readonly bool _isHotReloadEnabled;
public SerializationMethodsGenerator(GeneratorExecutionContext context)
{
_context = context;
_iosViewSymbol = context.Compilation.GetTypeByMetadataName("UIKit.UIView");
_objcNativeHandleSymbol = context.Compilation.GetTypeByMetadataName("ObjCRuntime.NativeHandle");
_androidViewSymbol = context.Compilation.GetTypeByMetadataName("Android.Views.View");
_intPtrSymbol = context.Compilation.GetTypeByMetadataName("System.IntPtr");
_jniHandleOwnershipSymbol = context.Compilation.GetTypeByMetadataName("Android.Runtime.JniHandleOwnership");
_javaCtorParams = new[] { _intPtrSymbol, _jniHandleOwnershipSymbol };
_configuration = context.GetMSBuildPropertyValue("Configuration")
?? throw new InvalidOperationException("The configuration property must be provided");
_isDebug = string.Equals(_configuration, "Debug", StringComparison.OrdinalIgnoreCase);
if (bool.TryParse(context.GetMSBuildPropertyValue("UnoForceHotReloadCodeGen"), out var isHotReloadEnabled))
{
_isHotReloadEnabled = isHotReloadEnabled;
}
else
{
_isHotReloadEnabled = _isDebug;
}
}
public override void VisitNamedType(INamedTypeSymbol type)
{
_context.CancellationToken.ThrowIfCancellationRequested();
foreach (var t in type.GetTypeMembers())View on GitHub (pinned to 0418340488)
Solutions
- Build through dotnet/MSBuild which always sets Configuration (Debug by default).
- If driving the generator programmatically, pass Configuration via generatorOptions/MSBuildProperties or AnalyzerConfigOptions.
- Pass it explicitly on the command line: dotnet build -p:Configuration=Debug.
Example fix
# before dotnet build # Configuration unset by custom host # after dotnet build -p:Configuration=Debug
Defensive patterns
Strategy: validation
Validate before calling
// Ensure Configuration is defined before building dotnet build -p:Configuration=Debug // or, in a custom host, seed GeneratorOptions MSBuildProperties["Configuration"] = "Debug"
Prevention
- Always build through dotnet/MSBuild so Configuration is set.
- When driving the generator programmatically, seed Configuration in the MSBuild properties.
When it happens
Trigger: The source generator executes in a context where the Configuration MSBuild property is not set (null), e.g. driven directly by a Roslyn driver or a test harness that did not seed global properties.
Common situations: Unit-testing the generator with a bare CSharpGeneratorDriver; a stripped custom build host; an MSBuild invocation that cleared Configuration.
Related errors
- The configuration property must be provided
- MSBuild property MSBuildProjectFullPath value {_projectFullP
- MSBuild property MSBuildProjectFullPath value {_projectFullP
- MSBuild property MSBuildProjectFullPath value {_projectFullP
- Cannot convert back if both custom values are the same
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/0b09c85678a04155.
Report an issue: GitHub.