Environment
• NCrunch Console Tool v5.21.0.10, and the NCrunch Visual Studio 2026 extension from the same release
• Windows, with HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled = 1
• Solution of .NET 10 projects, including a WinForms WinExe project that uses the WinForms ApplicationConfigurationGenerator
Problem
Running the console tool against the solution fails to build:
NCrunch.exe MySolution.sln /O NCrunchResults -NCrunchCacheStoragePath "C:\NCrunchCache"
The build fails with the error below, and Result: BuildFailure:
ERROR: System.Exception: Unable to instrument type ...ApplicationConfiguration due to exception: Unable to instrument method System.Void ...ApplicationConfiguration::Initialize() due to exception: System.IO.PathTooLongException: The path 'E:\NCrunchWS\62848\2\<Project>\obj\Release\net10.0-windows\System.Windows.Forms.Analyzers.CSharp\System.Windows.Forms.CSharp.Generators.ApplicationConfiguration.ApplicationConfigurationGenerator\ApplicationConfiguration.g.cs' could not be processed because it exceeded the maximum allowed length of 259 characters. Try setting your 'Workspace base path' setting closer to the root of your disk, or set the registry entry 'SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled'=1
The same solution builds and instruments successfully inside Visual Studio. The Visual Studio workspace base was E:\NCrunchWS\7964\7, which makes the equivalent path about 270 characters. That is longer than the failing console path, so the path length alone does not explain the difference.
What I tried
• LongPathsEnabled was already 1, as the error message suggests, so that didn't help.
• -WorkspaceBasePath "E:\NC" took effect (the workspace became E:\NC\48972\5), but the path was still 264 characters, so it still failed.
• Switching engine mode with /E to match the Visual Studio mode made no difference.
• The nCrunch.EngineHost48.x64.exe.config files in the console tool and the Visual Studio extension are identical.
Analysis
• The failure is logged by CILTaskProcessor threads whose process ID matches the console run (for example [PID:48972 … CILTaskProcessor-17]), and the workspace folder uses the same ID. So the CIL instrumentation runs inside the NCrunch.exe process itself.
• NCrunch.exe targets .NET Framework 4.0 and NCrunch.exe.config has no long-path settings. A .NET 4.0 process runs with legacy path handling, so the OS-level LongPathsEnabled setting is ignored.
• In Visual Studio the engine runs inside devenv, which targets .NET Framework 4.8, so the same instrumentation works.
Workaround
Add the following to C:\NCrunch Console Tool\NCrunch.exe.config:
<configuration>
<runtime>
<enforceFIPSPolicy enabled="false"/>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false;Switch.System.IO.BlockLongPaths=false" />
</runtime>
</configuration>
With this change the same command builds successfully. A filtered run (-TestsToExecuteAutomatically "HasCategory 'ServiceCentreIdentify'") ran 19 tests, all passing.
Request
1. Could the console tool ship with long-path support enabled in NCrunch.exe.config, or retarget NCrunch.exe to .NET Framework 4.6.2 or later?
2. Could the error message mention this cause? It currently suggests LongPathsEnabled, which has no effect on this process.
Build/Test Issues
Console tool fails with PathTooLongException at 259 characters even with LongPathsEnabled=1 (works in Visual Studio)
Started by Tim Long on 16 views
Remco NCrunch Developer
#18990
18 Nov 2026 05:40 UTC
Hi, thanks for sharing this issue with such detailed analysis.
There is no reason for me not to add the config setting you've suggested here. It will only improve things for people, so I've included it in v5.25 which has been released today.
Unfortunately the error you've hit here is coming from the platform (not from NCrunch), so I have no way to improve this experience without risk of masking other issues. Long path support is still very hit-and-miss on the Windows platform. I cannot make any guarantees that you won't have further problems by relying on it, but I'm glad to hear this adjustment works for your use case.
I have also added the above config settings for the grid node server, and they should also be effective for the MCP server.
There is no reason for me not to add the config setting you've suggested here. It will only improve things for people, so I've included it in v5.25 which has been released today.
Unfortunately the error you've hit here is coming from the platform (not from NCrunch), so I have no way to improve this experience without risk of masking other issues. Long path support is still very hit-and-miss on the Windows platform. I cannot make any guarantees that you won't have further problems by relying on it, but I'm glad to hear this adjustment works for your use case.
I have also added the above config settings for the grid node server, and they should also be effective for the MCP server.
Post a reply
Log in to reply.