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

Notification

Icon
Error

NCrunch Build failure on C# 6 projects
fcournoyer
#1 Posted : Thursday, March 23, 2017 10:36:39 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/22/2016(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Hi!

Recently moved back to a project, with ongoing development from my team, and am now with a new computer.
So I downloaded the latest version of NCrunch (3.6)
And I pulled the newest code from git, involving quite some changes.

In Visual Studio, everything compiles and runs successfully.
However NCrunch gives compile error about the language version
Quote:
: Feature 'nameof operator' is not available in C# 5. Please use language version 6 or greater.


Looking in details, the Project's Language Version was "Default".
Changed it to 6.0, still same problem. Could not find any NCrunch configuration about that.
Tried older version of NCrunch (3.2.0.3), same problem.

Windows 10 Pro, 64 bit
Visual Studio 2015 Pro
Projects are .NET 4.5.1

Some other projects that are using C# 6 features are compiled correctly with NCrunch. I can't see for now the difference why.

Any clues?
Francois


Remco
#2 Posted : Thursday, March 23, 2017 10:39:44 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 606 times
Was thanked: 697 time(s) in 667 post(s)
Hi Francois,

Thanks for sharing this problem.

I've had a couple of other users report similar problems. Unfortunately I can't tell why this is happening. Is there any chance you can share a sample project that reproduces this issue?
fcournoyer
#3 Posted : Thursday, March 23, 2017 10:49:39 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/22/2016(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Hi Remco!
Thanks for the quick response.
Sadly this contains sensitive code from the company I'm working for, that I can't share.

Obviously, making a small project using "nameof" operator does get compiled correctly by NCrunch.

If I find anything which fixes it, I'll let you know.

Francois
Remco
#4 Posted : Thursday, March 23, 2017 11:06:38 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 606 times
Was thanked: 697 time(s) in 667 post(s)
fcournoyer;10106 wrote:
Hi Remco!
Thanks for the quick response.
Sadly this contains sensitive code from the company I'm working for, that I can't share.


Understood. This is usually the case :(

fcournoyer;10106 wrote:

Obviously, making a small project using "nameof" operator does get compiled correctly by NCrunch.

If I find anything which fixes it, I'll let you know.


Thanks!
fcournoyer
#5 Posted : Tuesday, April 18, 2017 4:11:36 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/22/2016(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Hi Remco!

I finally found the problem, which is simply because of the "Default Platform" in the csproj.
It usually happened on older projects, which might have extra platforms existing (normally unused).

For example, a project "Foo" is always compiled using x86 (by the Configuration Manager in Visual Studio), and uses Language Version to 6 (or default).
However the AnyCPU platform also exists on that project, and it uses C#5, by having <LangVersion>5</LangVersion> in the PropertyGroup node.

Then, the default platform in the csproj is using the AnyCPU (thus the one used by NCrunch)
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

I found it by searching for <LangVersion>5</LangVersion> in all my csproj, and found those leftover platforms. A simple cleanup and then everything compiles!

So it's pretty much a user-side problem, and I don't know how you could detect it.

Francois
Remco
#6 Posted : Tuesday, April 18, 2017 11:34:59 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 606 times
Was thanked: 697 time(s) in 667 post(s)
Hi Francois,

Great find! I'm also not sure how I would detect this. But at least now I know that it's possible, which means I can advise other people when they report the problem to me. You'd be surprised at how common this is. I guess there might be something in the VS tooling that makes it happen unintentionally.
fcournoyer
#7 Posted : Tuesday, April 18, 2017 11:50:34 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/22/2016(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Well for us there's history reasons on why it happened.

First, at some point, we had a slow transition from VS 2013 to VS2015. In order that it compiles for everyone, we have set C#5 to all projects, so that people coding in 2015 don't break the build by using C#6 features not compatible for those on VS2013.

Also, normally when creating a project, it is initialized with AnyCPU. For most software, we after this change it to x86 specifically. We forgot to remove the AnyCPU target on some of them. And in that case, we do not change the "Default Platform" that NCrunch uses (defaults to AnyCPU).
So that means that those project got "C#5" to both AnyCPU and x86 platform.

Then, when deciding that everyone should use VS2015 and C#6, we manually changed most projects using Visual Studio "Project Properties". Some older project also had to keep their C#5 so we didn't do a mass-replace.
So you can see how only the project platforms compiled in Visual Studio got converted.

I'm the only one in the team using NCrunch, so when pulling "master", I started getting those error only with NCrunch.

Francois
1 user thanked fcournoyer for this useful post.
Remco on 4/18/2017(UTC)
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.047 seconds.