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

Notification

Icon
Error

Working with different TargetFrameworks
GlobalConcepts
#1 Posted : Tuesday, May 21, 2024 1:54:08 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 2/7/2013(UTC)
Posts: 52
Location: Germany

Thanks: 5 times
Was thanked: 6 time(s) in 6 post(s)
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
Quote:

<PropertyGroup Condition="'$(NCrunch)' == '1'">
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(NCrunch)' != '1'">
<TargetFramework>net462</TargetFramework>
</PropertyGroup>
Remco
#2 Posted : Tuesday, May 21, 2024 2:25:53 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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.
GlobalConcepts
#3 Posted : Tuesday, May 21, 2024 2:54:55 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 2/7/2013(UTC)
Posts: 52
Location: Germany

Thanks: 5 times
Was thanked: 6 time(s) in 6 post(s)
OK, what I have now is

Quote:

<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)
Remco
#4 Posted : Wednesday, May 22, 2024 12:14:52 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Quote:

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?

Quote:

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.
GlobalConcepts
#5 Posted : Wednesday, May 22, 2024 6:48:30 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 2/7/2013(UTC)
Posts: 52
Location: Germany

Thanks: 5 times
Was thanked: 6 time(s) in 6 post(s)
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
Remco
#6 Posted : Wednesday, May 22, 2024 7:00:12 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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.
GlobalConcepts
#7 Posted : Wednesday, May 22, 2024 7:02:07 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 2/7/2013(UTC)
Posts: 52
Location: Germany

Thanks: 5 times
Was thanked: 6 time(s) in 6 post(s)
Well, I still have the problem that the build fails on Grid Node
Remco
#8 Posted : Wednesday, May 22, 2024 12:04:44 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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?
GlobalConcepts
#9 Posted : Wednesday, May 22, 2024 12:39:28 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 2/7/2013(UTC)
Posts: 52
Location: Germany

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

1 user thanked GlobalConcepts for this useful post.
Remco on 5/23/2024(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.100 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download