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

Notification

Icon
Error

Build issue with 4.5 test project referencing multi-target core project
narshe
#1 Posted : Tuesday, March 28, 2017 2:51:56 PM(UTC)
Rank: Member

Groups: Registered
Joined: 3/12/2013(UTC)
Posts: 10
Location: United States of America

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
I have a project that is core and multi-targeted. NCrunch builds that fine. I get build successful for these project types:


  • net20
  • net35
  • net40
  • net45
  • net451
  • netstandard1.3
  • portable+net40+sl5+win8+wpa81+wp8


The test project is a .NET 4.5 project that is referencing the core project. The core project has netstandard1.3 as the first in the list, which is the only way I know how to choose the current target that visual studio runs under.

You can pull the code down to see if you like. It's on this branch. https://github.com/JoshC...e/CsvHelper/tree/vs2017

Thanks.
Remco
#2 Posted : Tuesday, March 28, 2017 9:18:08 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this problem.

This is caused by NCrunch failing to correlate the target framework of the test project with the main project. NCrunch assumes that for the target frameworks to be correlated, both projects would have them specified (using CPS projects). In truth, I didn't know that this setup would actually work under Visual Studio.

It should be possible to get this working by adding the following element to the XML of your test project (under the main propertygroup):

<TargetFramework>net45</TargetFramework>

I've noted this down to be fixed. Thanks again for reporting it.
narshe
#3 Posted : Tuesday, March 28, 2017 9:38:38 PM(UTC)
Rank: Member

Groups: Registered
Joined: 3/12/2013(UTC)
Posts: 10
Location: United States of America

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
This issue with doing that is it will only build net45 and not all the other types. This would work temporarily while developing, but isn't ideal.

If I switch the project over to using the new core project types (I'm assuming that's what CPS projects are), would this solve the issue? If I did that would I be able to specify multiple targets in the unit test project and would NCrunch run tests for each version of the framework then? I see NCrunch builds each type in the core project nicely.
Remco
#4 Posted : Tuesday, March 28, 2017 11:50:47 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
narshe;10141 wrote:
This issue with doing that is it will only build net45 and not all the other types. This would work temporarily while developing, but isn't ideal.

If I switch the project over to using the new core project types (I'm assuming that's what CPS projects are), would this solve the issue? If I did that would I be able to specify multiple targets in the unit test project and would NCrunch run tests for each version of the framework then? I see NCrunch builds each type in the core project nicely.


Yes, if your intention is to multi-target the tests so that each platform is tested individually, then you will need to switch the test project to CPS and multi-target the project to the platforms you wish to test for. NCrunch will handle this structure.

By setting your test project to .NET v4.5, you've basically instructed NCrunch (and all other tools) to only build your test project to .NET 4.5, and therefore it can only target the .NET 4.5 variant of your code under test.
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.045 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download