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/JoshClose/CsvHelper/tree/vs2017
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.
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.
narshe 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.