In some of my work projects (.NET 8 Asp.NET projects with .NET 8 xunit Test projects), NCrunch refuses to run unit tests, but I am able to run tests using the Test Explorer in Visual Studio 2022.
Here is some output from the NCrunch Diagnostic Output: (some parts will be redacted to prevent names from being shown)
[PID:23200 09:14:48.3861 InitialisationQueueTask-31] ERROR (Load): Error occurred during load of component at C:\REDACTED\REDACTED\REDACTED\REDACTED.csproj: System.Exception: An exception was thrown in the remote environment: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> nCrunch.Common.UserException: Errors occurred while trying to load the project file:
The targeting pack Microsoft.NETCore.App is not installed. Please restore and try again.
The targeting pack Microsoft.AspNetCore.App is not installed. Please restore and try again.
at nCrunch.Compiler.ComponentAnalysisContext.queryValuesFromMSBuild()
at nCrunch.Compiler.ComponentAnalysisContext.AnalyseComponentBuild()
at nCrunch.Compiler.RemoteBuildRunner.AnalyseComponentBuild(ComponentLoadParameters parameters)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.processCallMethodMessage(CallMethodMessage callMethodMessage)
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.ProcessMessageReturningResult(Byte[] data)
at nCrunch.TaskRunner.Ipc.RemoteProxyCommunicator.readMessage(Byte[] returnedData)
at nCrunch.TaskRunner.Ipc.RemoteProxyCommunicator.Invoke(String methodName, Object[] args)
at nCrunch.Compiler.RemoteBuildRunnerProxy.AnalyseComponentBuild(ComponentLoadParameters parameters)
at nCrunch.Core.BuildManagement.BuildProcessLauncher.<>c__DisplayClass4_0.<AnalyseComponentBuildInExternalProcess>b__0(IRemoteBuildRunner remoteBuildRunner)
at nCrunch.Core.BuildManagement.BuildProcessLauncher.executeTaskUsingExternalProcess(Action`1 task, EffectiveProcessorArchitecture processorArchitecture, GridClientId client, BuildSystemParameters buildSystemParameters, IList`1 customEnvironmentVariables, Nullable`1 taskId, GridClientDescription clientDescription, DotNetCoreSdkVersion dotNetCoreSdkVersion)
at nCrunch.Core.BuildManagement.BuildProcessLauncher.AnalyseComponentBuildInExternalProcess(ComponentLoadParameters parameters, IList`1 customEnvironmentVariables)
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.analyseComponentBuild(EffectiveProcessorArchitecture buildProcessorArchitecture, String targetFrameworkForMSBuild)
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.CreateComponentFromXml(FilePath projectFilePath, ParsedBuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, IDEVersion ideVersion, BuildEngineId buildEngineId, ComponentUniqueName componentName, TaskSettings componentTaskSettings, Exception parseException, String targetFrameworkForMsbuild, String visibleTargetFramework)
I looked up the Microsoft.NETCore.App and Microsoft.AspNetCore.App NuGet packages (since the error message mentioned them), and they seem to be related to .NET Core? One of them has a most recent release of 2024 (not good), so I'm not going to add that NuGet package to my test project.
Some more info:
- I have had Visual Studio 2026 and .NET 10 installed since Nov 2025. I haven't noticed any problems since then.
- Prior to April 2026, all of the code repositories (10-15 that I support) on my machine were .NET 8 projects.
- Around the first half of April 2026, I used Visual Studio 2026 to update a couple code repositories to use .NET 10 and csharp v14, but not this one. I mention it, this problem (that I'm posting about) started happening around 1-2 weeks ago. It's the only thing that might have any time-correlation with NCRunch not working, other than I updated by NCrunch license and downloaded the most recent NCRunch version at that time too.
- I have re-run the NCRunch configuration, without accepting any previous configuration. No improvement.
- I have searched for a global.json for this code repository/solution, and didn't find any.
- I have clicked the Rebuild button (Restart the NCRunch engine, resynchronize with VS, and rebuild all projects [Reset]) in the NCrunch Tests many times, trying to wipe out any invalid previous problems/configurations. It hasn't helped.
- I have updated NuGet Package references to the latest.
- I have reviewed the Test csproj, and removed some clutter, and it looks simple/good to me. I'll include it below, with some REDACTIONs.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<RootNamespace>REDACTED.Tests</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\REDACTED\REDACTED.csproj" />
</ItemGroup>
</Project>
I couldn't see an easy way to include my NCrunch configuration, so I didn't try to include that.
Ryan