novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
348 stars 42 forks source link

NET6_0 constants not properly defined #279

Open jeremyVignelles opened 2 years ago

jeremyVignelles commented 2 years ago

Context

For LibVLCSharp, we need to support Xamarin.Forms projects and old .net versions as well as the new .net6.0 tfms

The issue

A repro can be found here : https://github.com/jeremyVignelles/repro-tfm-msbuild-sdk-extras

It seems that NET6_0_OR_GREATER is not defined anywhere and NET6_0 is only defined in net6.0 and not net6.0-windows

It also seem that I can't use the new top-level statements in such projects.

clairernovotny commented 2 years ago

I noticed this earlier this week as well.

@dsplaisted Before I hunt this down, do you recall where these are defined or what controls them being defined?

clairernovotny commented 2 years ago

As a workaround, you should be able to set the DisableImplicitFrameworkDefines property to false. For some reason, the extras is setting that to true here:

https://github.com/novotnyllc/MSBuildSdkExtras/blob/main/Source/MSBuild.Sdk.Extras/Build/Platforms.targets#L45

I'm not sure exactly why anymore and I'll need to look closer to see what the side-effects are for all of the other project types.

dsplaisted commented 2 years ago

Here's the logic (or most of it at least): https://github.com/dotnet/sdk/blob/d33ef78b1e7710ce9dc461f73ff617958a6273e9/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets#L177-L241