Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NCrunch exception when building .net core xunit project
sgrassie
#1 Posted : Thursday, July 26, 2018 7:14:54 AM(UTC)
Rank: Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 14
Location: United Kingdom

Thanks: 2 times
Was thanked: 3 time(s) in 3 post(s)
I can't submit this as a bug through NCrunch because the wonderful corporate proxy I'm forced to go through appears to block it.

1. Created Xamarin Forms cross platform mobile application, with netstandard shared project.
2. Add <DesignTimeBuild Condition="'$(NCrunch)' == '1'">true</DesignTimeBuild> to the netstandard shared project so that it will build (as specified in a recent thread on the forum).
3. Add .net core 2.1 xunit test project using the default visual studio template.
4. Add some basic tests. One test uses a small PDF which is included in a resources .resx as a byte[] to test some Stream code.
5. NCrunch throws this exception to the output window when building the project:

Code:

An error occurred while analysing this project after it was built: NCrunch encountered an unexpected error occurred while building an environment to analyse an assembly: nCrunch.TaskRunner.Ipc.IpcConnectionClosedException: The connection has been closed
at nCrunch.Core.ProcessManagement.ExternalProcessManager.(ProcessorArchitecture , ProcessLoadParameters )
at nCrunch.Core.ProcessManagement.ExternalProcessManager.LoadExternalProcess(ProcessLoadParameters parameters, GridClientId client)
at nCrunch.Core.TestManagement.TestRunnerProcess..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.TestManagement.TestRunnerProcess.(Nullable`1 , FilePath , GridClientId , CustomEnvironmentVariable[] )
at nCrunch.Core.TestManagement.TestRunnerProcess..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.TestManagement.TestRunnerProcess.LoadTestRunnerProcessForProjectReturningProcessId(SnapshotComponent snapshotComponent, IList`1 componentsInProcess, TestFrameworkDescription[] testingFrameworks, Nullable`1 newProcessTag, FilePath solutionFilePath, GridClientId client, CustomEnvironmentVariable[] customEnvironmentVariables)
at nCrunch.Core.Processing.AnalysisTaskLogic.DoProcessTaskAndReturnSuccessFlag()


I saved the bug report .zip file, if you let me know where to email it to I'll send it over.
Remco
#2 Posted : Friday, July 27, 2018 12:09:14 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,974

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
Hi, thanks for posting!

Note that Xamarin projects are not currently supported by NCrunch, so there isn't much I can do to help with this issue.

It's possible this is being caused by a malformed reference due to platform targeting issues.

Try adding Nuget references to the following packages from your test project to see if this resolves the issue:

<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
sgrassie
#3 Posted : Friday, July 27, 2018 9:43:57 AM(UTC)
Rank: Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 14
Location: United Kingdom

Thanks: 2 times
Was thanked: 3 time(s) in 3 post(s)
Remco, I removed the reference to the xamarin forms project from the xUnit project, and fixed up the tests so they are essentially empty. NCrunch still fails to build the xUnit project, throwing the same error.

Just to confirm, using the trick in the thread I linked to, NCrunch does build the xamarin project.

I forgot to mention in my first post, I get a message saying: "Unable to restore require Nuget packages for .NET Core test environment".

Following your suggestion above, I added package references to the xUnit project for the following three packages (which were listed in the output window).

System.Diagnostics.TraceSource v4.3.0
System.Runtime.Loader v4.3.0
xunit.runner.utility v2.2.0

Once I got it to build, I added the reference back to the Xamarin.Forms project, re-enabled the tests to properly test things in the xamarin.forms project and everything thing builds, test tests run. In fact, NCrunch, Resharper and the VS Test Runner all agree that the same tests fail for the same (currently expected) reasons.

So I would say that your assertion that Xamarin projects are not currently (officially) supported is perhaps not 100% accurate :)
Remco
#5 Posted : Friday, July 27, 2018 11:30:30 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,974

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
sgrassie;12471 wrote:

I forgot to mention in my first post, I get a message saying: "Unable to restore require Nuget packages for .NET Core test environment".


When you have problems like this one, a message like this is definitely a red flag. NCrunch has certain package dependencies of its own, and when it can't restore those packages, it often won't be able to build test environments without .NET Core bugging out in weird ways. Most likely the steps you've taken have resulted in the necessary packages being restored, so that now the problem is completely gone :)

sgrassie;12471 wrote:

So I would say that your assertion that Xamarin projects are not currently (officially) supported is perhaps not 100% accurate :)


I tend to toe a careful line when making claims about supported toolsets. NCrunch probably will work with a very broad range of toolsets and frameworks without any testing or work required from our side, but there is an important difference between the application working with a toolset and the dev team providing support for such a setup. The big problem with Xamarin is that it is a very broad set of tools and that have changed considerably over the last few years. For me to confidently say that we support it would require me to ensure that all existing and prior Xamarin project types would work with NCrunch out of the box with no changes necessary, and that any newly introduced changes would be tested with all edge cases handled. Right now, I can't make this statement. We simply haven't had the dev capacity to tackle Xamarin (yet).
sgrassie
#4 Posted : Monday, August 6, 2018 2:57:07 PM(UTC)
Rank: Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 14
Location: United Kingdom

Thanks: 2 times
Was thanked: 3 time(s) in 3 post(s)
sgrassie;12471 wrote:

...
Following your suggestion above, I added package references to the xUnit project for the following three packages (which were listed in the output window).

System.Diagnostics.TraceSource v4.3.0
System.Runtime.Loader v4.3.0
xunit.runner.utility v2.2.0
...


For what it's worth, here's an update on this after I updated to NCrunch 3.18.02.

I've removed the package references in the unit test project, and it still builds, and the tests run without problems. Additionally the warning about being unable to restore required nuget packages for .net core test environment is gone.

I've left the previously mentioned hack in place, although I understand that I could now use the 'Custom build properties' feature to achieve the same goal without unnecessarily messing with the .csproj, but :shrug:, it's fine as it is.
Remco
#6 Posted : Tuesday, August 7, 2018 12:22:10 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,974

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
Thanks for confirming that v3.18 works better in this area. There was a significant change introduced in v3.18 to try and address the platform dependency issues caused by NCrunch's own assemblies targeting earlier versions of .NET Core. I would hope that this change would render your primary issue impossible.

Yes, the 'Custom build properties' setting can also be used to override your build behaviour :)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.059 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download