Build/Test Issues

NCrunch seems to select the wrong target framework

Started by jnm236 on 6,936 views

I'm not able to get the NUnit solution to build with NCrunch. I wish I knew of a way to look into NCrunch's MSBuild logs the way I'm used to with msbuildlog.com, but I eventually pared it down to this repro: Wrong target framework chosen.zip

It looks like a netcoreapp2.0 project is referencing the other project's netstandard1.6 output rather than the netstandard2.0 output:

Class1.cs (4, 20): The type or namespace name 'ClassLibrary' could not be found (are you missing a using directive or an assembly reference?)


NCrunch 3.14.0.1, VS 15.6.6

dotnet --list-sdks
1.1.8 [C:\Program Files\dotnet\sdk]
2.1.101 [C:\Program Files\dotnet\sdk]
2.1.102 [C:\Program Files\dotnet\sdk]
2.1.103 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.300-preview2-008324 [C:\Program Files\dotnet\sdk]
2.2.0-preview1-007622 [C:\Program Files\dotnet\sdk]

Anything else I can provide to help track this down?
Thanks! 😃

Edited

Thanks for sharing this problem. The sample solution was really useful in figuring this out quickly.

When a multi-targeted project is referenced by other projects of different target platforms, the nature of this reference becomes ambiguous. For example, it could be considered perfectly valid for a netcoreapp2.0 project to reference a netstandard1.6 project, or a netstandard2.0 project. Neither answer is 'wrong', though it's clear that there must be a precedence.

You've managed to find a situation where the precedence in resolving this reference is different under NCrunch to the standard VS tooling.

I have a fix pending to resolve this issue. Since we're expecting to release v3.15 this weekend, I'll push it out with the public release. If the public release gets held up, I'll get you a dev build instead :)
Awesome news! I'm glad it was worth it!
Please don't go to any special trouble on my account. It's a nice-to-have.
You are awesome, by the way. Your turnaround time is always incredible. 😃
Thanks! :)
Just realized that <TargetFramework> in the thread title was eaten rather than escaped, sorry for the silly-looking title. 😛

Just tried 3.15 on the NUnit solution. Now all the netcoreapp2.0 projects are all building fine, but the netcoreapp1.1 projects all stopped building with messages like these:

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
The type 'Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.


They shouldn't be trying to reference the .NET Standard 2.0 reference assemblies. I'll try to create a small repro; let me know if you don't need it.

I feel bad; I probably should have taken you up on the dev build offer, just to give you the opportunity to squash all the bugs in one release.

Edited

Thanks, this looks like more magic to me. netcoreapp1.1 is magically tied to netstandard1.6, while netcoreapp2.0 is magically tied to netstandard2.0.

I wonder about the others. Looks like we'll need to build a whole table to figure this out.
Thanks, that's very useful :)

Post a reply

Log in to reply.