Build/Test Issues

NCrunch has encountered an internal error: System.Exception: System.IO.PathTooLongException

Started by TURNSKIN on 1,179 views

After installing Visual Studio 2026 Insiders (or maybe it was before, not sure) I have started to get these errors:

[SPOILER]
[PID:40992 16:49:22.3305 Core-5] Console tool is using engine mode: [Undetermined]
[PID:40992 16:49:22.3305 Core-5] Beginning end-to-end run of solution using tools from platform 'MSBuild for VS2022'
[PID:10468 16:50:11.1425 ?-27] Could not find a part of the path 'C:\_NCrunchWorkspaces\40992\10\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.Reconciliation.Migrations\obj\Debug\net9.0\MyApplication.MyConsolidation.Reconciliation.Migrations.GeneratedMSBuildEditorConfig.editorconfig'.
[PID:40992 16:50:11.2365 LocalBuildTask-28] ERROR (Build): MyApplication.MyConsolidation.Reconciliation.Migrations: C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.Managed.Core.targets (191): Could not find a part of the path 'C:\_NCrunchWorkspaces\40992\10\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.Reconciliation.Migrations\obj\Debug\net9.0\MyApplication.MyConsolidation.Reconciliation.Migrations.GeneratedMSBuildEditorConfig.editorconfig'.

[PID:10468 16:50:13.5955 ?-27] Could not find a part of the path 'C:\_NCrunchWorkspaces\40992\9\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.Database.Migrations\obj\Debug\net9.0\MyApplication.MyConsolidation.Database.Migrations.GeneratedMSBuildEditorConfig.editorconfig'.
[PID:40992 16:50:13.6585 LocalBuildTask-27] ERROR (Build): MyApplication.MyConsolidation.Database.Migrations: C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.Managed.Core.targets (191): Could not find a part of the path 'C:\_NCrunchWorkspaces\40992\9\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.Database.Migrations\obj\Debug\net9.0\MyApplication.MyConsolidation.Database.Migrations.GeneratedMSBuildEditorConfig.editorconfig'.

[PID:40992 16:50:17.9865 LocalBuildTask-28] ERROR: System.Exception: Unable to instrument type MyApplication.MyConsolidation.DAL.Entities.Eod.Cache.AgreementEntity due to exception: System.Exception: Unable to instrument method System.Void MyApplication.MyConsolidation.DAL.Entities.Eod.Cache.AgreementEntity::.cctor() due to exception: System.IO.PathTooLongException: The path 'C:\_NCrunchWorkspaces\40992\12\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.DAL\obj\Debug\net9.0\MemoryPack.Generator\MemoryPack.Generator.MemoryPackGenerator\MyApplication.MyConsolidation.DAL.Entities.Eod.Cache.AgreementEntity.MemoryPackFormatter.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
at nCrunch.Common.IO.DiskPath..ctor(String absolutePath, Boolean pathIsChecked)
at nCrunch.Common.IO.FilePath..ctor(String absoluteFilePath, Boolean isAbsoluteFilePathChecked)
at nCrunch.Common.IO.FilePath.FromAbsolutePath(String absoluteFilePath)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.☻(CilSequencePoint ☻)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.☻(CilManipulationOperation ☻, CilMethodDefinition ♥, CilTypeDefinition ♣, CilMethodBody, Boolean ♠)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.☻(CilTypeDefinition ☻, CilManipulationOperation ♥, IInstrumentationFilter[] ♣)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.☻(CilTypeDefinition ☻, CilManipulationOperation ♥, IInstrumentationFilter[] ♣)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.♣.♥()
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.♣.♥()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.♥.☻()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.Instrument(IInstrumentationFilter[] instrumentationFilters, PerfTracker perfTracker)
at nCrunch.Compiler.CilProcessingTasks.CilInstrumentationTask.ProcessTask(IBuiltAssembly builtAssembly, ComponentInstrumentationParameters instrumentationParameters, BuildOutput output)
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.☻()
[PID:40992 16:50:18.2205 LocalBuildTask-28] ERROR: System.IO.PathTooLongException: The path 'C:\_NCrunchWorkspaces\40992\12\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.DAL\obj\Debug\net9.0\MemoryPack.Generator\MemoryPack.Generator.MemoryPackGenerator\MyApplication.MyConsolidation.DAL.Entities.Eod.Cache.AgreementEntity.MemoryPackFormatter.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
at nCrunch.Common.IO.DiskPath..ctor(String absolutePath, Boolean pathIsChecked)
at nCrunch.Common.IO.FilePath..ctor(String absoluteFilePath, Boolean isAbsoluteFilePathChecked)
at nCrunch.Common.IO.FilePath.FromAbsolutePath(String absoluteFilePath)
at nCrunch.Compiler.CoverageReportStructure.☻(Dictionary`2 ☻, String ♥)
at nCrunch.Compiler.CoverageReportStructure.♥.☻(KeyValuePair`2 ☻)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at nCrunch.Compiler.CoverageReportStructure.☻(CilAssembly ☻, Dictionary`2 ♥)
at nCrunch.Compiler.CoverageReportStructure.FromAssembly(CilAssembly assembly, Dictionary`2 codeFilePathsByWorkspaceFilePath, DirectoryPath instrumentationParametersForegroundOutDir)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.ExtractCoverageReportStructure()
at nCrunch.Compiler.CilProcessingTasks.CilExtractCoverageReportStructureTask.ProcessTask(IBuiltAssembly builtAssembly, ComponentInstrumentationParameters instrumentationParameters, BuildOutput output)
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.☻()
[PID:40992 16:50:18.2835 LocalBuildTask-28] ERROR (Build): MyApplication.MyConsolidation.DAL: (0): NCrunch has encountered an internal error: System.Exception: System.IO.PathTooLongException: The path 'C:\_NCrunchWorkspaces\40992\12\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.DAL\obj\Debug\net9.0\MemoryPack.Generator\MemoryPack.Generator.MemoryPackGenerator\MyApplication.MyConsolidation.DAL.Entities.Eod.Cache.AgreementEntity.MemoryPackFormatter.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
at nCrunch.Common.IO.DiskPath..ctor(String absolutePath, Boolean pathIsChecked)
at nCrunch.Common.IO.FilePath..ctor(String absoluteFilePath, Boolean isAbsoluteFilePathChecked)
at nCrunch.Common.IO.FilePath.FromAbsolutePath(String absoluteFilePath)
at nCrunch.Compiler.CoverageReportStructure.☻(Dictionary`2 ☻, String ♥)
at nCrunch.Compiler.CoverageReportStructure.♥.☻(KeyValuePair`2 ☻)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at nCrunch.Compiler.CoverageReportStructure.☻(CilAssembly ☻, Dictionary`2 ♥)
at nCrunch.Compiler.CoverageReportStructure.FromAssembly(CilAssembly assembly, Dictionary`2 codeFilePathsByWorkspaceFilePath, DirectoryPath instrumentationParametersForegroundOutDir)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.ExtractCoverageReportStructure()
at nCrunch.Compiler.CilProcessingTasks.CilExtractCoverageReportStructureTask.ProcessTask(IBuiltAssembly builtAssembly, ComponentInstrumentationParameters instrumentationParameters, BuildOutput output)
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.☻()
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.ProcessTasks(IReservedCapacity reservedBackgroundCapacity)
at nCrunch.Compiler.RemoteBuildRunner.☻(ComponentInstrumentationParameters ☻, BuildOutput ♥, IBackgroundTaskProcessor ♣)
at nCrunch.Compiler.RemoteBuildRunner.PerformPostProcessingOfBuiltAssembly(ComponentInstrumentationParameters instrumentationParameters, BuildOutput output, IBackgroundTaskProcessor backgroundTaskProcessor)
at nCrunch.Core.BuildManagement.BuildEnvironment.☻()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender, Guid taskId, GridClientDescription clientDescription, Boolean extractCoverageReportStructure)

[PID:40992 16:50:48.0805 ?-1] Reporting engine execution results
Execution result based on (ConsoleOutput):

Load errors: False
Failed tasks: True
Failed tests: True
Not run tests: False
Impacted tests:


Result: BuildFailure
[PID:40992 16:50:48.7365 ?-1] Shutting down engine

[/SPOILER]

When I try to run with Rider I get this error on building project:

NCrunch: If you are experiencing problems in getting this project to build, have a look at https://www.ncrunch.net/documentation/troubleshooting_project-build-issues
..\..\..\..\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.Managed.Core.targets (191, 5): Could not find a part of the path 'C:\_NCrunchWorkspaces\23772\89\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.Database.Migrations\obj\Debug\net9.0\MyApplication.MyConsolidation.Database.Migrations.GeneratedMSBuildEditorConfig.editorconfig'.


P.S. `LongPathsEnabled` is set to 1
Hi, thanks for sharing this.

Unfortunately long path support is not reliable through the platform as a whole, so we have no way to fully support it under NCrunch.

I recommend moving your workspace closer to the disk root. Try changing your workspace base path (currently 'C:\_NCrunchWorkspaces') to something shorter, like 'C:\WS'.
I tried to move workspace closer to root, but still nCrunch console fail with similar error could not be processed because it exceeded the maximum allowed length of 259 characters.:
[SPOILER]
λ nCrunch MyApplication.MyConsolidation.sln -NCrunchCacheStoragePath c:\_n\_s

NCrunch Console Tool v5.18.0.2
Copyright c 2010-2025 Remco Software Ltd
Usage of this tool is permitted only under the terms described in License.rtf



This product is licensed to user (support/maintenance expires 23-Oct-5743)

[PID:21208 14:03:21.0609 Core-5] Console tool is using engine mode: [Undetermined]
[PID:21208 14:03:21.0759 Core-5] Beginning end-to-end run of solution using tools from platform 'MSBuild for VS2026'
^C
c:\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation (master -> origin)
λ nCrunch MyApplication.MyConsolidation.sln -NCrunchCacheStoragePath c:\_n\_s

NCrunch Console Tool v5.18.0.2
Copyright c 2010-2025 Remco Software Ltd
Usage of this tool is permitted only under the terms described in License.rtf



This product is licensed to user (support/maintenance expires 23-Oct-5743)

[PID:48908 14:07:47.5544 Core-5] Console tool is using engine mode: [Undetermined]
[PID:48908 14:07:47.5544 Core-5] Beginning end-to-end run of solution using tools from platform 'MSBuild for VS2026'
[PID:48908 14:08:36.4294 LocalBuildTask-17] ERROR: System.Exception: Unable to instrument type MyApplication.MyConsolidation.DAL.Cache.AgreementEntity due to exception: System.Exception: Unable to instrument method System.Void MyApplication.MyConsolidation.DAL.Cache.AgreementEntity::.cctor() due to exception: System.IO.PathTooLongException: The path 'C:\_n\48908\13\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.DAL\obj\Debug\net9.0\MemoryPack.Generator\MemoryPack.Generator.MemoryPackGenerator\MyApplication.MyConsolidation.DAL.Cache.AgreementEntity.MemoryPackFormatter.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
at nCrunch.Common.IO.DiskPath..ctor(String absolutePath, Boolean pathIsChecked)
at nCrunch.Common.IO.FilePath..ctor(String absoluteFilePath, Boolean isAbsoluteFilePathChecked)
at nCrunch.Common.IO.FilePath.FromAbsolutePath(String absoluteFilePath)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.alignDocumentStateWithSequencePoint(CilSequencePoint sequencePoint)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.instrumentMethod(CilManipulationOperation manipulationOperation, CilMethodDefinition method, CilTypeDefinition type, CilMethodBody body, Boolean isInstanceConstructor, HashGenerationContext context)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.instrumentType(CilTypeDefinition type, CilManipulationOperation manipulationOperation, IInstrumentationFilter[] instrumentationFilters, HashGenerationContext context)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.instrumentType(CilTypeDefinition type, CilManipulationOperation manipulationOperation, IInstrumentationFilter[] instrumentationFilters, HashGenerationContext context)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.<>c__DisplayClass34_1.<Instrument>b__2()
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.<>c__DisplayClass34_1.<Instrument>b__2()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.<>c__DisplayClass34_0.<Instrument>b__0()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.Instrument(IInstrumentationFilter[] instrumentationFilters, PerfTracker perfTracker)
at nCrunch.Compiler.CilProcessingTasks.CilInstrumentationTask.ProcessTask(IBuiltAssembly builtAssembly, ComponentInstrumentationParameters instrumentationParameters, BuildOutput output)
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.processTask()
[PID:48908 14:08:36.5234 LocalBuildTask-17] ERROR: System.IO.PathTooLongException: The path 'C:\_n\48908\13\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.DAL\obj\Debug\net9.0\MemoryPack.Generator\MemoryPack.Generator.MemoryPackGenerator\MyApplication.MyConsolidation.DAL.Cache.AgreementEntity.MemoryPackFormatter.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
at nCrunch.Common.IO.DiskPath..ctor(String absolutePath, Boolean pathIsChecked)
at nCrunch.Common.IO.FilePath..ctor(String absoluteFilePath, Boolean isAbsoluteFilePathChecked)
at nCrunch.Common.IO.FilePath.FromAbsolutePath(String absoluteFilePath)
at nCrunch.Compiler.CoverageReportStructure.getMappedToPath(Dictionary`2 codeFilePathsByWorkspaceFilePath, String absoluteOrRelativePath)
at nCrunch.Compiler.CoverageReportStructure.<>c__DisplayClass42_0.<collectAllFiles>b__1(KeyValuePair`2 f)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at nCrunch.Compiler.CoverageReportStructure.collectAllFiles(CilAssembly assembly, Dictionary`2 codeFilePathsByWorkspaceFilePath)
at nCrunch.Compiler.CoverageReportStructure.FromAssembly(CilAssembly assembly, Dictionary`2 codeFilePathsByWorkspaceFilePath, DirectoryPath instrumentationParametersForegroundOutDir)
at nCrunch.Compiler.CilProcessingTasks.CilExtractCoverageReportStructureTask.ProcessTask(IBuiltAssembly builtAssembly, ComponentInstrumentationParameters instrumentationParameters, BuildOutput output)
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.processTask()
[PID:48908 14:08:36.5704 LocalBuildTask-17] ERROR (Build): MyApplication.MyConsolidation.DAL: (0): NCrunch has encountered an internal error: System.Exception: System.IO.PathTooLongException: The path 'C:\_n\48908\13\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.DAL\obj\Debug\net9.0\MemoryPack.Generator\MemoryPack.Generator.MemoryPackGenerator\MyApplication.MyConsolidation.DAL.Cache.AgreementEntity.MemoryPackFormatter.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
at nCrunch.Common.IO.DiskPath..ctor(String absolutePath, Boolean pathIsChecked)
at nCrunch.Common.IO.FilePath..ctor(String absoluteFilePath, Boolean isAbsoluteFilePathChecked)
at nCrunch.Common.IO.FilePath.FromAbsolutePath(String absoluteFilePath)
at nCrunch.Compiler.CoverageReportStructure.getMappedToPath(Dictionary`2 codeFilePathsByWorkspaceFilePath, String absoluteOrRelativePath)
at nCrunch.Compiler.CoverageReportStructure.<>c__DisplayClass42_0.<collectAllFiles>b__1(KeyValuePair`2 f)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at nCrunch.Compiler.CoverageReportStructure.collectAllFiles(CilAssembly assembly, Dictionary`2 codeFilePathsByWorkspaceFilePath)
at nCrunch.Compiler.CoverageReportStructure.FromAssembly(CilAssembly assembly, Dictionary`2 codeFilePathsByWorkspaceFilePath, DirectoryPath instrumentationParametersForegroundOutDir)
at nCrunch.Compiler.CilProcessingTasks.CilExtractCoverageReportStructureTask.ProcessTask(IBuiltAssembly builtAssembly, ComponentInstrumentationParameters instrumentationParameters, BuildOutput output)
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.processTask()
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.ProcessTasks(IReservedCapacity reservedBackgroundCapacity)
at nCrunch.Compiler.RemoteBuildRunner.processBuiltAssembly(ComponentInstrumentationParameters instrumentationParameters, BuildOutput output, IBackgroundTaskProcessor backgroundTaskProcessor)
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender, Guid taskId, GridClientDescription clientDescription, Boolean extractCoverageReportStructure)

[PID:48908 14:08:48.1014 ?-1] Reporting engine execution results
Execution result based on (ConsoleOutput):

Load errors: False
Failed tasks: True
Failed tests: True
Not run tests: False
Impacted tests:


Result: BuildFailure
[PID:48908 14:08:48.6954 ?-1] Shutting down engine
[/SPOILER]
While nCrunch for Rider works OK.
Sorry to hear that.

In this case, the only option remaining is to try and find a way to reduce the length of the path. It looks like the main culprit is a temporary file being used by the build system under your 'obj' directory. Changing the intermediate output path for the project might allow you to set this at a higher level directory so it doesn't hit the path limit. Depending on the files involved, there may be build options available for suppressing them.

Another option could be to examine the project involved to see which files it references from further up in the directory structure. If you're able to eliminate upwards/sideways dependencies, NCrunch then doesn't need to pad out the directory inside a deeper structure. So for example, instead of:
\_n\48908\13\Projects\MyApplication.MyCalculations\MyApplication.MyConsolidation\MyApplication.MyConsolidation.DAL\

You could get:
\_n\48908\13\

The easiest way to find which files are causing this is to examine the contents of the workspace being built by NCrunch. Simply right click the project in the NCrunch Tests Window, then choose Advanced->Browse to workspace. The files underneath \_n\48908\13 can give some clue as to which files are causing the problem. Copying them into the project directory or moving them further down in the structure would help to collapse the workspace and reduce the length of the paths inside it.

Post a reply

Log in to reply.