Skip to content

[Bug]: VS previewer fails to start when the build output has long file paths #208

Open

Description

@lmejiauxd

Describe the bug

The previewer won't start when the project's build output contains a file with a long path. The error happens while the extension copies the build output into its own folder (%LOCALAPPDATA%\AvaloniaUI\com.AvaloniaUI.Net.VisualStudio\Previewer...), before the preview runs.

That folder's path is longer than bin\Debug\net10.0, so a file whose path is fine in bin can go over 260 characters once copied, and then the copy fails:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\<user>\AppData\Local\AvaloniaUI\com.AvaloniaUI.Net.VisualStudio\Previewer\PieChartTest_ZA0bRhZj8U80lAh4\Test\Folder with a loooooooooooooooong name\Nested folder with an even loooooooooooooooooooooooooooooooooooooooooonger name\File with a looooooooooooooooooooooooong name.txt'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at AvaloniaUI.Previewer.Process.Output.ShadowCopyOutputStrategy.<PrepareShadowCopyAsync>d__10.MoveNext()
   at AvaloniaUI.Previewer.Process.Output.ShadowCopyOutputStrategy.<PrepareAsync>d__7.MoveNext()
   at AvaloniaUI.Previewer.Process.PreviewerProcessFactory.<CreateLaunchOptionsAsync>d__12.MoveNext()

Long paths are enabled in Windows, but that doesn't seem to help, possibly because Visual Studio does not support that setting.

Interestingly, if the file's path is already over 260 characters in bin, the extension only logs a warning (Shadow copy source not found), skips the file, and the previewer starts fine. It only fails completely when the path is OK in bin but too long in the previewer's folder.

To Reproduce

  1. Create a new Avalonia app.
  2. Add a text file at a nested path, for example Test\Folder with a loooooooooooooooong name\Nested folder with an even loooooooooooooooooooooooooooooooooooooooooonger name\File with a looooooooooooooooooooooooong name.txt, with CopyToOutputDirectory="PreserveNewest". Its full path in bin should be under 260 characters, but over 260 once it's in the previewer's folder.
  3. Build and open any .axaml file in the previewer.

Product(s)

Avalonia for Visual Studio

Platform

Windows

License Tier

Pro

Avalonia version

12.1.3

Tool/Control Version

Avalonia for VS 12.3.2.0 - VS 18.10.3

Relevant log output

Additional context

No response

Activity

  1. added theissue type on Oct 9, 2026
  2. maxkatz6 commented on Oct 12, 2026

    @maxkatz6
    Member

    @lmejiauxd thank you. We identified the issue.

  3. self-assigned this
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions