Skip to content

CI: MAUI Windows sample build fails with path too long (CS0016) #3611

@mattleibow

Description

@mattleibow

Problem

The MAUI sample build fails on Windows CI in the Samples stage with CS0016 errors:

CSC(0,0): Error CS0016: Could not write to output file
'D:\a\1\s\output\samples\Basic\Maui\SkiaSharpSample\obj\Release\net10.0-windows10.0.19041.0\win-x64\generated\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.XamlGenerator\GlobalXmlns.g.cs'
-- 'Could not find a part of the path ...'

This affects multiple source generators: XAML generator, binding source generator, and WinRT AOT source generator.

Root Cause

The MAUI source generators create deeply nested output paths under obj/. When the CI workspace is already deep (D:\a\1\s\output\samples\Basic\Maui\...), the generated file paths exceed the Windows MAX_PATH limit (260 characters).

The samples-generate cake task copies samples to output/samples/, adding an extra directory layer that pushes the paths over the limit.

Impact

5/10 recent main builds have Samples stage failures on Windows due to this. The macOS and Linux Samples jobs pass (no path length limit).

Recommendations

  1. Shorten the output path — Use a shorter output directory in the pipeline, e.g. D:\s instead of D:\a\1\s.

  2. Enable long paths — Set LongPathsEnabled in the Windows registry on CI agents, or use the MSBuild property:

    <PropertyGroup>
      <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
    </PropertyGroup>
  3. Shorten project name — Rename SkiaSharpSample to something shorter in the generated output, or flatten the output directory structure.

  4. Use .NET 10 long path support — Ensure the CI agent has the HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled registry key set to 1.

Data

5/10 recent main builds (156326, 156346, 156367, 156384, 156423) show this failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    os/Windows-ClassicIssues running on Microsoft Windows using Win32 APIs (Windows.Forms or WPF)type/bug

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions