unoplatform/uno · error · InvalidOperationException

MSBuild property MSBuildProjectFullPath value {_projectFullP

Error message

MSBuild property MSBuildProjectFullPath value {_projectFullPath} is not valid

What it means

Thrown during XamlCodeGeneration initialization when Path.GetDirectoryName returns null for the value of the 'MSBuildProjectFullPath' MSBuild property. GetDirectoryName returns null when the input is null, empty, or a root path without a directory component.

Source

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

			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");

			_includeXamlNamespaces = context.GetMSBuildPropertyValue("IncludeXamlNamespacesProperty");

			_analyzerSuppressions = context.GetMSBuildPropertyValue("XamlGeneratorAnalyzerSuppressionsProperty").Split(_commaArray, StringSplitOptions.RemoveEmptyEntries);

			_resourceFiles = context.GetMSBuildItemsWithAdditionalFiles("PRIResource").ToArray();

View on GitHub (pinned to 0418340488)

Solutions

  1. Ensure the build is invoked through a standard MSBuild/dotnet build pipeline that sets MSBuildProjectFullPath to the full project file path.
  2. If running the generator programmatically, populate MSBuildProjectFullPath with a valid absolute path to the .csproj file.
  3. Check for any custom .targets that might be overriding or clearing MSBuildProjectFullPath.

Example fix

// In a test harness, provide the property:
generatorContext.SetMSBuildPropertyValue("MSBuildProjectFullPath", @"C:\Projects\MyApp\MyApp.csproj");
Defensive patterns

Strategy: validation

Validate before calling

// Ensure MSBuildProjectFullPath is valid when invoking the generator:
// var path = context.GetMSBuildPropertyValue("MSBuildProjectFullPath");
// if (string.IsNullOrWhiteSpace(path) || !Path.IsPathRooted(path))
//     throw new ArgumentException("MSBuildProjectFullPath must be a valid absolute path");

Prevention

When it happens

Trigger: The MSBuildProjectFullPath property is null, empty, or set to an invalid/root-only value during source generation.

Common situations: A custom build host or test harness does not provide MSBuildProjectFullPath; the property was overridden to an invalid value; the project file path contains unusual characters that confuse path resolution.

Related errors


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