visualstudio.xunit icon indicating copy to clipboard operation
visualstudio.xunit copied to clipboard

Generic support for .NET 5+ TFM's

Open clairernovotny opened this issue 5 years ago • 6 comments

Follow-up from https://github.com/xunit/visualstudio.xunit/pull/229, we need more than a quick-fix that enables .NET 6 and higher the right way.

@nohwnd @nkolev92 @ViktorHofer

clairernovotny avatar Aug 03 '20 17:08 clairernovotny

I found #229 very curious, because it seems like they went away from the more parsable version of the target framework name and instead just give you net5-style naming. I wonder what the motivation there is. Maybe @damianedwards can help us understand why this is.

bradwilson avatar Aug 03 '20 17:08 bradwilson

cc @dsplaisted

ViktorHofer avatar Aug 03 '20 18:08 ViktorHofer

The reason for the change is that the more parsable version of the target framework (.NETCoreApp, Version=v4.5) didn't have a way to represent the platform name / version which can now be part of the target framework in .NET 5 and above. So the NuGet API now returns the NuGet short framework name, which can represent the platform info, if the target framework is .NET 5 and higher.

dsplaisted avatar Aug 03 '20 18:08 dsplaisted

@nohwnd based on this issue (we are still hardcoding net5.0), I'm surprised that net6.0 testing works for us in dotnet/runtime. Do you know why? Also do you know how to better fix this long-term?

ViktorHofer avatar Oct 14 '20 10:10 ViktorHofer

As I understand it, the NuGet API where this value was coming from (I think it was NuGetFramework.DotNetFrameworkName) was reverted to only return the TargetFramework. If you want to know the platform information you now have to look at a different property.

dsplaisted avatar Oct 14 '20 10:10 dsplaisted

Daniel is right, the change was reverted somewhere in RC1 and my original fix can be reverted as well (Ideally when net5.0 is released).

@ViktorHofer It works for you because of that, and because the code on nuget.frameworks takes net as a pattern and can convert that from the short framework name to .NETCoreApp,Version=v6.0 (or how exactly it is spelled in the DLL attributes), and vice versa. The adapters (e.g. mstest or xunit) will match on .NETCoreApp* to determine if this is a .NET Core dll.

nohwnd avatar Oct 14 '20 10:10 nohwnd

It's not clear to me from this thread whether this fix should be upgraded or removed, so I at least made it better. Making it go away would also be fine.

https://github.com/xunit/visualstudio.xunit/commit/a4e9f5389cb410820034c4fcc212b18e2e68666c#diff-85765f830c78860b59bc0674f13f37560b05936bf9b613255b6ebc13b0c9e295R121

bradwilson avatar May 22 '23 08:05 bradwilson