unoplatform/uno · error · InvalidOperationException

MSBuild property MSBuildProjectFullPath value {_projectFullP

Error message

MSBuild property MSBuildProjectFullPath value {_projectFullPath} is not valid

What it means

BindableTypeProvidersGenerationTask reads the MSBuildProjectFullPath property to derive the project directory for output. Path.GetDirectoryName returns null only when the path is empty, a drive root, or otherwise has no directory component, which the generator treats as an invalid project path and throws InvalidOperationException. The generator only runs when validPlatform && !isDesignTime && isApplication && !disableBindableTypeProvidersGeneration.

Source

Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs:69

			public string[] AnalyzerSuppressions { get; set; } = Array.Empty<string>();

			internal void Generate(GeneratorExecutionContext context)
			{
				try
				{
					var validPlatform = PlatformHelper.IsValidPlatform(context);
					var isDesignTime = DesignTimeHelper.IsDesignTime(context);
					var isApplication = PlatformHelper.IsApplication(context);

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

					if (validPlatform && !isDesignTime && isApplication && !disableBindableTypeProvidersGeneration)
					{
						_cancellationToken = context.CancellationToken;

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

						// Defaults to 'false'
						_ = bool.TryParse(context.GetMSBuildPropertyValue("UnoXamlResourcesTrimming"), out _xamlResourcesTrimming);

						_intermediateOutputPath = context.GetMSBuildPropertyValue("IntermediateOutputPath");
						_intermediatePath = Path.Combine(
							_projectDirectory,
							_intermediateOutputPath
						);
						_assemblyName = context.GetMSBuildPropertyValue("AssemblyName");

						_defaultNamespace = context.GetMSBuildPropertyValue("RootNamespace");

						_dependencyPropertySymbol = context.Compilation.GetTypeByMetadataName(XamlConstants.Types.DependencyProperty);
						_dependencyObjectSymbol = context.Compilation.GetTypeByMetadataName(XamlConstants.Types.DependencyObject);

						_javaObjectSymbol = context.Compilation.GetTypeByMetadataName("Java.Lang.Object");
						_nsObjectSymbol = context.Compilation.GetTypeByMetadataName("Foundation.NSObject");

View on GitHub (pinned to 0418340488)

Solutions

  1. Confirm the build is invoked through MSBuild/dotnet so MSBuildProjectFullPath is populated.
  2. Inspect the .csproj for an empty/invalid <Project> path or a misconfigured SDK import.
  3. If you intentionally drive the generator headless, set the property explicitly: dotnet build -p:MSBuildProjectFullPath=/abs/path/to/Project.csproj.

Example fix

# before: property missing/unset
dotnet build /some/dir
# after: ensure MSBuildProjectFullPath resolves, or pass it explicitly
dotnet build /abs/path/to/Project.csproj
Defensive patterns

Strategy: validation

Validate before calling

// Assert the MSBuild property resolves before invoking a build that activates this generator
var path = Environment.GetEnvironmentVariable("MSBuildProjectFullPath");
if (string.IsNullOrWhiteSpace(path) || System.IO.Path.GetDirectoryName(path) == null)
    throw new InvalidOperationException("MSBuildProjectFullPath is not set/valid; build via dotnet/MSBuild.");

Prevention

When it happens

Trigger: MSBuildProjectFullPath is empty, whitespace, a bare root (e.g. '/'), or unset at the time the generator executes, while all four activation conditions are true.

Common situations: Building through a non-standard host or test harness that does not define MSBuildProjectFullPath; a corrupted/empty .csproj; invoking the generator outside a normal MSBuild build.

Related errors


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