unoplatform/uno · error · InvalidOperationException

MSBuild property MSBuildProjectFullPath value {_projectFullP

Error message

MSBuild property MSBuildProjectFullPath value {_projectFullPath} is not valid

What it means

DependencyObjectAvailabilityGenerator reads MSBuildProjectFullPath to locate the project directory and throws InvalidOperationException when Path.GetDirectoryName returns null (empty/root/unset path). It activates only when validPlatform && (_xamlResourcesTrimming || _isUnoUISolution).

Source

Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/DependencyObjectAvailabilityGenerator.cs:64

					var validPlatform = PlatformHelper.IsValidPlatform(context);

					if (!bool.TryParse(context.GetMSBuildPropertyValue("UnoXamlResourcesTrimming"), out _xamlResourcesTrimming))
					{
						_xamlResourcesTrimming = false;
					}

					if (!bool.TryParse(context.GetMSBuildPropertyValue("_IsUnoUISolution"), out _isUnoUISolution))
					{
						_isUnoUISolution = false;
					}

					if (validPlatform && (_xamlResourcesTrimming || _isUnoUISolution))
					{
						_defaultNamespace = context.GetMSBuildPropertyValue("RootNamespace");

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

						_ = bool.TryParse(context.GetMSBuildPropertyValue("UnoDisableBindableTypeProvidersGeneration"), out var disableBindableTypeProvidersGeneration);

						_intermediateOutputPath = context.GetMSBuildPropertyValue("IntermediateOutputPath");
						_intermediatePath = Path.Combine(
							_projectDirectory,
							_intermediateOutputPath
						);
						_assemblyName = context.GetMSBuildPropertyValue("AssemblyName");
						_dependencyObjectSymbol = context.Compilation.GetTypeByMetadataName("Microsoft.UI.Xaml.DependencyObject");
						_additionalLinkerHintAttributeSymbol = context.Compilation.GetTypeByMetadataName("Uno.Foundation.Diagnostics.CodeAnalysis.AdditionalLinkerHintAttribute");

						var additionalLinkerHintSymbols = FindAdditionalLinkerHints(context);

						var modules = from ext in context.Compilation.ExternalReferences
									  let sym = context.Compilation.GetAssemblyOrModuleSymbol(ext) as IAssemblySymbol
									  where sym != null
									  from module in sym.Modules

View on GitHub (pinned to 0418340488)

Solutions

  1. Build via MSBuild/dotnet so MSBuildProjectFullPath is defined.
  2. If trimming is not needed locally, disable it (unset UnoXAMLResourcesTrimming / set UnoXamlResourcesTrimming=false).
  3. Verify the .csproj SDK/imports are intact so the path property resolves.

Example fix

# before: trimming on, path missing
dotnet build -p:UnoXamlResourcesTrimming=true # MSBuildProjectFullPath unset
# after
dotnet build /abs/path/to/Project.csproj -p:UnoXamlResourcesTrimming=true
Defensive patterns

Strategy: validation

Validate before calling

// If you enable trimming or build the Uno solution, ensure the path property is set
var path = Environment.GetEnvironmentVariable("MSBuildProjectFullPath");
if (string.IsNullOrWhiteSpace(path) || System.IO.Path.GetDirectoryName(path) == null)
    throw new InvalidOperationException("MSBuildProjectFullPath unset; build via dotnet/MSBuild or disable UnoXamlResourcesTrimming.");

Prevention

When it happens

Trigger: MSBuildProjectFullPath is empty, a drive root, or unset while the generator is active (UnoXamlResourcesTrimming=true or building inside the Uno solution).

Common situations: Building with UnoXamlResourcesTrimming enabled through a host that omits MSBuildProjectFullPath; building the Uno solution from a stripped/corrupted project file.

Related errors


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