Build/Test Issues

Working with different TargetFrameworks

Started by GlobalConcepts on 3,277 views

The title might sound a little bit strange.

With .NET SDK Project Style it's possible to define more than one TargetFramework.
I already worked with projects that have multiple TargetFrameworks. The tests are working and everything looks fine.
This Project + Test both have the same TargetFrameworks defined.

So what exactly is my problem?
We're developing libraries for an application that limits target framework to .net 4.6.2.
On the other side we're using JustMock that raised framework to 4.7.2 with their latest release.

If I define TargetFramework of my project with net462 and reference it in my test project with TargetFramework, NCrunch tells me that net472 is not defined in project.assts.json - what is true.
Btw: This works with non-sdk project style.

Therefore I've tried to define TargetFrameworks with net472;net462 but now this results in "The target "_SplitProjectReferencesByFileExistence" does not exist in the project.

Does someone have an idea how to solve this problem?

This is also not working :-D

<PropertyGroup Condition="'$(NCrunch)' == '1'">
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(NCrunch)' != '1'">
<TargetFramework>net462</TargetFramework>
</PropertyGroup>
Could you try setting 'TargetFrameworks' using the custom build properties setting and see if this works for you? This should be cleaner than adding conditions in the project itself and the NCrunch project parser will work better with it.
OK, what I have now is


<ProjectConfiguration>
<Settings>
<CustomBuildProperties>
<Value>TargetFramework = net472</Value>
<Value>TargetFrameworks = net462;net472</Value>
</CustomBuildProperties>
</Settings>
</ProjectConfiguration>


One of them seems to work. But only on local, not on Grid Node.
Are there separate Grid Node Custom Build Properties to set?
It also does not work with TargetFramework set by Directory.Build.props (not a problem)

Are there separate Grid Node Custom Build Properties to set?


The grid node operates the same way in this area as the client does. How is it failing on the node?


It also does not work with TargetFramework set by Directory.Build.props (not a problem)


Yes, unfortunately we don't support TargetFramework overrides in Directory.Build.props.
ok; so I have to define my TargetFramework(s) directly in the project. As long as it works ... ✔️

The NCrunch Tests Window still returns a Trace Output - while Server is our Grid Node - that project.assets.json does not contain a target for net472 by mentioning the path on client.
It makes no different if I set those custom properties only on the project to test, the project containing the tests or inside the "share settings" / whole solution
Thanks. Is there anything here we need to address? Sorry I'm a bit confused about the current state of affairs and if there's anything that needs fixing here.
Well, I still have the problem that the build fails on Grid Node
Can you confirm for me what type of project this is? Is it just a standard .NET Framework class library?

project.assets.json on the grid node should be more or less a copy from the client, so the targets in the file should be a match between the machines when going through the build system.

Does this problem happen consistently or intermittently?

Can you confirm whether the grid node has the same SDKs installed as the client?
It is defined to be compiled as a class library, yes.
The SDKs are the same.

I've deleted my Directory.Build.props, removed the CustomBuildProperties disabled and reenabled NCrunch and now it's working.
Seems we cannot use them in this case. They worked perfectly fine with projects using net8.0 but not with projects using different TargetFrameworks :-(

Ticket closed

Post a reply

Log in to reply.