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

Notification

Icon
Error

NCrunch seems to select the wrong target framework
jnm236
#1 Posted : Friday, April 20, 2018 12:32:27 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
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:

Quote:
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! 😃
Remco
#2 Posted : Friday, April 20, 2018 1:42:32 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 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 :)
jnm236
#3 Posted : Friday, April 20, 2018 1:59:13 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
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.
jnm236
#4 Posted : Saturday, April 21, 2018 12:36:55 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
You are awesome, by the way. Your turnaround time is always incredible. 😃
1 user thanked jnm236 for this useful post.
Remco on 4/21/2018(UTC)
Remco
#5 Posted : Saturday, April 21, 2018 12:45:43 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! :)
jnm236
#6 Posted : Saturday, April 21, 2018 4:36:28 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
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:

Quote:
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.
jnm236
#7 Posted : Saturday, April 21, 2018 4:53:42 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Repro was easy. Sort of looks like the netcoreapp1.1 project is now referencing the dependency project's netstandard2.0 output.

Wrong target framework chosen, obverse.zip
Remco
#8 Posted : Saturday, April 21, 2018 11:07:49 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)
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.
jnm236
#9 Posted : Saturday, April 21, 2018 11:15:27 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
To me this is inherently expected. Are you pretty familiar with https://github.com/dotnet/standard/blob/master/docs/versions.md?

Interactive version: http://immo.landwerth.net/netstandard-versions
Remco
#10 Posted : Saturday, April 21, 2018 11:33:06 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)
Thanks, that's very useful :)
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.052 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download