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

Notification

Icon
Error

Even the simplest .NET Core project fails to build under NCrunch
Tim Long
#1 Posted : Wednesday, July 26, 2017 3:41:29 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/20/2016(UTC)
Posts: 13
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
Hi there. Noting that .NET Core support has arrived, I am filled with enthusiasm because I now have a way to test some of my UWP code. What I intend to do is put all my ViewModel code into a .NET Standard library, then include that into a .NET Core test project (class library). VS 2017 creates a class library that targets .NET Core 1.1 so I've gone with the defaults.

However, I've fallen at the first fence. I can't get NCrunch to successfully build even the simplest of .NET Core projects (it builds fine in Visual Studio 2017 and I'm using Preview - 15.3.0 Preview 4.0). Note that I have to use this version because I need support for UWP on Windows 10 IoT Creator's Update, build 15063 and that requires VS 2017 preview.

So I'm trying to run this simple test project as "Debug | Any CPU" which is the default configuration created by Visual Studio. It's defaults all the way. Here's the code:

Code:
using Xunit;

namespace TA.UWP.Tests
{
    class NCrunchIceBreakerTests
    {
        [Fact]
        void TheFundamentalTruthsStillApply()
        {
            Assert.True(true); // True is still true
        }
    }
}


Simple, right? Obviously I'm referencing xUnit (2.2.0) via NuGet. This builds in VS (can't run it because it's a class library). However in NCrunch I get a variety of unconvincing results.

Right now, I'm getting the red "pending" icon and in the status it says "Failed last build, rebuilding". But it isn't rebuilding and it never does.

Either I'm missing something really obvious (very possible) or something is broken... any suggestions please? I so want this to work because more than half my code is targetting UWP and/or .NET Core and I don't currently have a convincing test strategy for it.


Tim Long
#2 Posted : Wednesday, July 26, 2017 3:57:50 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/20/2016(UTC)
Posts: 13
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
All right, it looks like I'm not understanding how test runners work in .NET Core. I tried re-creating my project as a "Unit test application" and now it is building and running the tests in NCrunch. I thought that NCrunch would be able to run tests from a class library, like it does for .NET Framework projects. All these frameworks, platforms and standards are confusing, to say the very least!

The errors in NCrunch are a bit confusing as well though, since it looks like the project cannot build. It seems like it's not actually a "build" problem because the project builds fine in VS. So it would be better if NCrunch gave a more meaningful error, like "Can't run tests from a class library".

Regards,
Tim
Remco
#3 Posted : Wednesday, July 26, 2017 11:11:49 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 622 times
Was thanked: 725 time(s) in 690 post(s)
Hi Tim,

Thanks for sharing this problem. It shouldn't be required to create a unit test library using a VS template to run NCrunch on a .NET Core project, simply referencing a test framework package should be enough. I'm not sure what went wrong here, but I do have a theory. The synchronisation between VS and NCrunch around project creation and setup under .NET Core isn't yet bullet proof. It's likely that NCrunch managed to get out of sync with the changes happening in VS while the project was created, and managed to get an incomplete snapshot of the project. If this happens, just resetting the engine should usually solve the problem. If you still have any persistent error messages, please do share these and I'll try to investigate and advise.
GibSral
#4 Posted : Tuesday, August 01, 2017 1:17:32 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/1/2014(UTC)
Posts: 5
Location: Germany

Thanks: 2 times
I have a similar issue.
When building a .net core project ncrunch fails with the following log entry (I replaced my local user with $USER$ in the paths):

ENGINE - [14:50:24.962-Core-27] Event [ErrorEvent:[Error:
Context: (global)
Category: Internal
Message: Unable to find version 1.1.0 of .NET Core. Please make sure your project is targeting a version of .NET Core that is installed in your Nuget packages directory at C:\Users\$USER$\.nuget\packages
Details: System.Exception: Unable to find version 1.1.0 of .NET Core. Please make sure your project is targeting a version of .NET Core that is installed in your Nuget packages directory at C:\Users\$USER$\.nuget\packages
bei nCrunch.Core.PlatformTypes.DotNetCoreBuildExtender.(FilePath )
bei nCrunch.Core.PlatformTypes.DotNetCoreBuildExtender.(SnapshotComponent , BuildOutput )
bei nCrunch.Core.PlatformTypes.DotNetCoreBuildExtender.ProcessSuccessfulBuildOutput(SnapshotComponent component, BuildOutput buildOutput, IList`1 componentReferences)
bei nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender)
bei nCrunch.Core.Processing.BuildTaskLogic.DoProcessTaskAndReturnSuccessFlag()
bei nCrunch.Core.Processing.TaskLogic.ProcessTaskAndReturnSuccessFlag()
bei nCrunch.Client.Processing.LocalProcessingTask.ProcessTaskAndReturnSuccessFlag()
bei nCrunch.Client.Processing.ProcessingQueue..()
]] is being processed on Core thread with subscriber: ErrorHandler.


This also happens when creating a fresh project.
ncrunch searches for the 1.1.0 version of .net core but version 1.1.2 is installed and used in the project.

This only happens in Version 3.10.0.20.
After downgrading to Version 3.9.0.1 ncrunch builds .net core projects without errors

Greetings
Lars
Remco
#5 Posted : Wednesday, August 02, 2017 12:25:02 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 622 times
Was thanked: 725 time(s) in 690 post(s)
Hi Lars,

Thanks for sharing this problem.

.NET Core seems to have some kind of indirection between the requested version of .NET Core and the version eventually resolved by the runtime. The logic underneath here doesn't have a strong pattern of consistency that I've recognised and it seems to change with almost every minor VS update. The exception NCrunch is throwing is because the TargetFramework specified in your project is likely to be netcoreapp1.1, but .NET Core 1.1.0 isn't available under your Nuget packages.

The easiest way to get this to work is to make sure you have Microsoft.NetCore.App/1.1.0 Nuget package installed. This will get NCrunch past the check that throws the exception, then the .NET Core runtime magic will hopefully resolve to the right version when it constructs a test environment.
Der-Albert.com
#6 Posted : Monday, August 07, 2017 5:37:19 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/17/2011(UTC)
Posts: 90

Was thanked: 16 time(s) in 14 post(s)
Hi,

i had just a similar problem.

I installed the NCrunch Grid Node Server on a seperate Machine (to offload the work).

Installed was i need, VS 2017.3 Preview 7, .NET Core SDK 1.0.4, .NET Core 2 Preview 2 etc.

Made lokal Build of a an dotnet new mvc App, for 1.1 and 2.0.

Then switch on distributed Processing. Error Occurs, Unabled to find Version 1.1 of .NET Core.

I had to switch to NCrunch Grid Node Service from SYSTEM logon, to the local user account. Then everything works.

I assume the Problem ist the Bug, that if .NET Core2 Preview 2 is installed,
the intial run of dotnet restore (or something like this) for a 1.1 project on a new account (SYSTEM in that case) fails. You have two uninstall .NET Core 2, then make dotnet restore for the 1.1 project, install .NET Core 2 again.

I've done this in the right order for the local account, but it is not possible to do for SYSTEM. But, would explain this behaviour and fx in my case.

Best Regards

Albert



1 user thanked Der-Albert.com for this useful post.
Remco on 8/7/2017(UTC)
Users browsing this topic
Guest (4)
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.054 seconds.