Build/Test Issues

IpcConnectionClosedException unable to find Ben.Demystifier

Started by lukesch on 2,429 views

I'm having trouble running netcore unit tests. The error complains about Ben.Demystifier on the ncrunch taskrunner. I've tried adding this as a reference in my test project with no luck. The problem disappears if I specify "Copy referenced assemblies to workspace." Can anything be done to avoid needing to set this property on all of my netcore test projects?

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.TaskRunner.Ipc.Fast.IpcStream.Connect(String ipcName, Boolean isHost)
   at nCrunch.TaskRunner.Ipc.Fast.FastIpcClient.Connect(String ipcName)
   at nCrunch.Core.ProcessManagement.DefaultProcessLoader.ConnectToProcess(ExternalProcess externalProcess, ProcessLoadParameters parameters, Action`1 outOfBandMessageHandler)
   at nCrunch.Core.ProcessManagement.ExternalProcessManager..()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.Core.ProcessManagement.ExternalProcessManager.(EffectiveProcessorArchitecture , ProcessLoadParameters , Boolean )

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: 'Ben.Demystifier', version: '0.1.2'
    path: 'lib/netstandard2.0/Ben.Demystifier.dll'


My project looks like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AssemblyName>Internal.OSS.AdoAdapterCoreTests</AssemblyName>
    <RootNamespace>Internal.OSS.AdoAdapterCoreTests</RootNamespace>
    <NoWarn>NU1605</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="FluentAssertions" />
    <PackageReference Include="HtmlAgilityPack" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" />
    <PackageReference Include="Microsoft.VisualStudio.Services.Client" />
    <PackageReference Include="Microsoft.VisualStudio.Services.Governance.Client" />
    <PackageReference Include="Microsoft.VisualStudio.Services.InteractiveClient" />
    <PackageReference Include="Microsoft.VisualStudio.Services.Release.Client" />
    <PackageReference Include="Microsoft.VisualStudio.Services.ServiceHooks.WebApi" />
    <PackageReference Include="MSTest.TestAdapter" />
    <PackageReference Include="MSTest.TestFramework" />
    <PackageReference Include="NSubstitute" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\..\dev\Common\src\AdoAdapterCore\AdoAdapterCore.csproj" />
    <ProjectReference Include="..\..\..\..\dev\Common\src\Logger\GenericLogger.csproj" />
    <ProjectReference Include="..\..\..\..\dev\Common\src\SecureStringUtils\SecureStringUtils.csproj" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="AdoAdapterFactoryTests.cs" />
    <Compile Include="AdoAdapterTests.cs" />
    <Compile Include="Proxy\GraphHttpClientProxyTests.cs" />
    <Compile Include="Proxy\IdentityHttpClientProxyTests.cs" />
    <Compile Include="Proxy\ProxyTestBase.cs" />
    <Compile Include="Throttling\ConcurrentRequestLimiterTests.cs" />
    <Compile Include="Throttling\ExecuteWithRetriesExecutorTests.cs" />
    <Compile Include="Throttling\ExecuteWithRetriesFactoryTests.cs" />
    <Compile Include="Throttling\ServiceThrottlingStatusTests.cs" />
    <Compile Include="Throttling\ThrottlingConfigurationTests.cs" />
    <Compile Include="Throttling\VsoTraceEventTests.cs" />
    <Compile Include="Throttling\VstsRequestExecutorFactoryTests.cs" />
    <Compile Include="Throttling\VstsRequestExecutorTests.cs" />
  </ItemGroup>
</Project>

Edited

Hi, thanks for sharing this issue.

The package in question (Ben.Demystifier) is not used by NCrunch. My suspicion is that this package is a dependency of one of the other packages or projects referenced by your project, and that for a reason I presently can't identify, the runtime expects it to exist in the build output directory.

I've tried building a replicate project using the info you've given me, but it seems that I'm missing a critical package (Microsoft.VisualStudio.Services.Governance.Client) which doesn't seem to be available on Nuget right now. The latest NSubstitute also gives me some complaints about compatibility with netcoreapp3.1.

My expectation is that this dependency configuration is always going to require the 'Copy referenced assemblies to workspace' to be turned on, because something in the referenced code set expects the environment to be that way. You might be able to narrow down which dependency is causing the problem by taking a copy of your project and stripping it down until the error goes away.
lukesch wrote:It looks like Ben.Demystifier is used by Microsoft.VisualStudio.Services.InteractiveClient. What can I do with this information?


Most likely, very little. We can try and dig a bit deeper to see if we can find out why the platform expects the assembly to be copied to local, but the most likely scenario is the one in which 'Copy referenced assemblies to workspace' needs to be left on.

We've tried in many cases to rig NCrunch so that you don't need to turn on this setting, but there are serious limits to what we can feasibly do when the build and runtime system itself is working against us.

I wasn't able to produce the problem when creating a project referencing the Microsoft.VisualStudio.Services.InteractiveClient package, so there must be more to this than just a simple dependency. Can you confirm whether you have the required version of the missing package inside the Nuget packages directory under your user profile?
While I investigate that, let me ask a different question. Is there a way for ncrunch to detect this is a netsdk/netcore style test project and automatically turn this 'Copy referenced assemblies to workspace' setting on?
lukesch wrote:While I investigate that, let me ask a different question. Is there a way for ncrunch to detect this is a netsdk/netcore style test project and automatically turn this 'Copy referenced assemblies to workspace' setting on?


In the current build of NCrunch, there is no config setting that will do this for you. You can, however, set the 'Copy referenced assemblies to workspace' setting at a higher level in your configuration so that it applies to all projects and solutions.

In terms of modifying NCrunch so that it will do this in general, there are no plans to do this, as the majority of netcore projects can build without the setting enabled and therefore would perform better.
This post has been deleted.
This post has been deleted.

Post a reply

Log in to reply.