Skip to content

.NET Framework test runners are not long path awareΒ #5179

Closed

Description

@DragonTea135

Description

If the test project is targeting .NET Framework version 4.8.1 or lower, long paths can not be used in tests.

Currently, this can be worked around by prepending \\?\ to every long path or by making paths shorter.

This problem may be solved by making test runners long path aware by adding the necessary elements to the testhost manifest:

  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
    </windowsSettings>
  </application>

Steps to reproduce

  1. Ensure long paths are enabled in the registry:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
  1. Clone the sample solution https://github.com/DragonTea135/vstest-long-path-sample.

  2. Run tests using Visual Studio, dotnet test or vstest.console.

Expected behavior

All tests should pass in both net481 and net8 projects.

Actual behavior

Test that creates a directory with a long path in the net481 project throws an exception:

System.IO.PathTooLongException : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Lower target framework versions give the same result.

Environment

Windows 11 version 23H2
Visual Studio version 17.11.0
VSTest version 17.11.0

Activity

  1. nohwnd commented on Aug 19, 2024

    @nohwnd
    Member

    Thank you for the suggestion, we are currently not adding new features to vstest. I've marked this as up for grabs, in case you or someone else wants to implement the change.

  2. ChrisGuzak commented on Mar 13, 2026

    @ChrisGuzak
    Member

    The longPathAware setting was added to the real vstest.console.exe and testhost.exe under Extensions\TestPlatform, but the backwards-compat wrapper at CommonExtensions\Microsoft\TestWindow\vstest.console.exe is still missing it.

    This wrapper is the binary on the Developer Command Prompt PATH (see where vstest.console.exe). It's a .NET Framework shim (RockSteady.Program) that delegates to the real binary via AppDomain.ExecuteAssembly. Since it's the process the OS sees, its manifest controls longPathAware behavior for any path resolution that happens before handoff.

    Same gap as the maxversiontested issue in #5041 β€” the wrapper is owned by VS Test Explorer (internal), not the vstest repo.

    This is really a problem with the VS owned helper. I filed this feedback item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help-WantedThe issue is up-for-grabs, and can be claimed by commenting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions