Hi. I recently got a new computer and have done a clean install of all my tools, including VS2026 Insiders and NCrunch. Some of my projects build and run tests OK, but I have one problematic one that fails all tests (it was working on the old computer). I guess it's probably a missing dependency, but I'm not sure what. I've tried searching the NCrunch docs for "prerequisites" and can't find any mention. Here's the error:
NCrunch encountered an error while trying to construct an environment to execute this test: The NCrunch task process failed to correctly initialise with the following exception: nCrunch.TaskRunner.Ipc.IpcConnectionClosedException: The NCrunch task process was unexpectedly terminated. For information on how to troubleshoot this problem, please see https://www.ncrunch.net/documentation/troubleshooting_process-terminated-unexpected-error
at nCrunch.TaskRunner.Ipc.Fast.IpcReader.Initialise()
at nCrunch.Core.ProcessManagement.DefaultProcessLoader.ConnectToProcess(ExternalProcess externalProcess, ProcessLoadParameters parameters, Action`1 outOfBandMessageHandler)
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.ProcessManagement.ExternalProcessManager.launchProcess(EffectiveProcessorArchitecture processorArchitecture, ProcessLoadParameters parameters, Boolean forceRedirectOutput)
The trace output for the process is as follows:
Error:
An assembly specified in the application dependencies manifest (nCrunch.TaskRunner.DotNetCore.20.x64.deps.json) was not found:
package: 'System.Collections.NonGeneric', version: '4.3.0'
path: 'lib/netstandard1.3/System.Collections.NonGeneric.dll'
I can't work out what's causing this. I see that the error mentions both netstandard1.3 and DotNetCore.20, which isn't installed. Is this a prerequisite?
NCrunch has a number of package dependencies that are needed by its test adapters. To avoid installer bloat, these aren't packaged with the product. Instead, when the engine is enabled, NCrunch does a scan of your Nuget packages cache and then it builds a small project containing the dependencies before running MSBuild to force them to restore.
Normally you'll get a warning or error if there's a dependency missing that it was unable to restore (before hitting the runtime failure you've experienced), but regardless the fix is the same. Try creating a small project in VS that references this specific version of the mentioned package. Then let the system restore it, and the problem should go away.
NCrunch has a number of package dependencies that are needed by its test adapters. To avoid installer bloat, these aren't packaged with the product. Instead, when the engine is enabled, NCrunch does a scan of your Nuget packages cache and then it builds a small project containing the dependencies before running MSBuild to force them to restore.
Normally you'll get a warning or error if there's a dependency missing that it was unable to restore (before hitting the runtime failure you've experienced), but regardless the fix is the same. Try creating a small project in VS that references this specific version of the mentioned package. Then let the system restore it, and the problem should go away.
That doesn't appear to have worked, unfortunately. I added a class library project in the offending solution targeting net10.0 and manually added a reference to the allegedly missing NuGet package. The project builds, as does my test project, but all the tests are still throwing the same error. I tried disabling and re-enabling the engine, and restarting Visual Studio, etc. - just in case.
Can you check the contents of your Nuget package cache to see if the package is installed in the expected location?
Normally the file should be at C:\Users\USER\.nuget\packages\System.Collections.NonGeneric\4.3.0\lib\netstandard1.3\System.Collections.NonGeneric.dll
If the binary is not there but the package directory is, try deleting C:\Users\USER\.nuget\packages\System.Collections.NonGeneric\4.3.0 and restoring it again.
Remco wrote:Can you check the contents of your Nuget package cache to see if the package is installed in the expected location?
Yes, it was there. I deleted it and re-restored anyway, no joy.
However, I noticed that the problem has now moved to a different package: 'System.Runtime.Loader', version: '4.3.0'
So I installed that, and the problem moved to: 'System.Runtime.Serialization.Formatters', version: '4.3.0'
It seems like there is some sort of systemic issue here, like nCrunch is trying to use a framework that's just not installed, not just the odd missing package.
There is a list of packages that NCrunch requires which it should automatically restore itself.
I think your Nuget package cache is corrupt. Try renaming the package root (with the IDE closed) to see if re-downloading the packages resolves the issue.
Remco wrote:There is a list of packages that NCrunch requires which it should automatically restore itself.
I think your Nuget package cache is corrupt. Try renaming the package root (with the IDE closed) to see if re-downloading the packages resolves the issue.
It's not that. I've tried clearing the nuget cache, reinstalling NCrunch and Visual Studio. The reason I'm having this issue is that I've just started out with a clean slate on a new computer and something that nCrunch needs is missing. I've done several hours worth of troubleshooting myself and I'm really struggling with this. My AI suggested that I file the following report:
NCrunch Version: 5.20.0.2
Visual Studio Version: 2026
.NET SDK: 10.0.102
NCrunch is attempting to use nCrunch.TaskRunner.DotNetCore.20.x64
for projects targeting net8.0 and net10.0, resulting in missing
assembly errors like:
package: 'System.Collections.NonGeneric', version: '4.3.0'
path: 'lib/netstandard1.3/System.Collections.NonGeneric.dll'
The same test project works correctly for net481 target.
Test project configuration:
<TargetFrameworks>net481;net8.0;net10.0</TargetFrameworks>
Note that the solution builds and runs fine in Visual Studio. It's public if you'd like to check it out and have a look at my config: https://github.com/Tigra-Astronomy/TA.Utilities/tree/feature/mvvm
Thanks for these extra details. Sorry about the frustration that I'm sure this has been causing you.
I'm wondering if you could check for me whether you are able to run NCrunch on a simple test project created from one of the standard VS templates that is targeting the same version of .NET and the same test framework? This will help to establish whether the issue is something related to your solution or whether it's tied to your system configuration.
Also it would be great if you could submit a bug report right after you've hit the failure. The log file in the report might yield some interesting information about what is happening on your system.
Thanks for sending through the bug report. The report contains an error that should be showing up in your NCrunch tests window. The package names were duplicated in the error, so I fixed this manually:
ERROR: Unable to restore required Nuget packages for .NET Core test environment
NCrunch was unable to restore Nuget packages required to build a test environment for this solution, due to an error: The msbuild command returned exit code 1: "c:\program files\microsoft visual studio\18\insiders\MSBuild\Current\Bin\msbuild.exe" /t:Restore "C:\Users\Tim.Long\AppData\Local\NCrunch\53816\PackageRestore\restorePackages.csproj"
The following packages do not exist under the Nuget packages folder for the active user profile, yet they have been flagged by NCrunch as potentially needed for normal operation. NCrunch has attempted to restore these files via an MSBuild restore step, which has either failed or not returned the expected result. It's possible that these packages may not be needed for building projects or running tests in your environment. If you experience downstream problems with NCrunch on this solution, it is recommended you restore or download the packages manually.
Note that the restore of packages may fail if NCrunch is being hosted under a windows account that does not have sufficient rights to store files in the Nuget packages directory.
... Basically some environments seem to have this problem. I haven't been able to reproduce it to understand why, but I think it's somehow related to security configuration. Make yourself a csharp project that references the specified versions of the above packages and let VS's package restore pull them down, and you should be up and running.