-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetTargetPlatformIdentifier vs TargetPlatformIdentifier conditions #7359
Comments
This looks like an awkward mismatch between the new world and the old--the
Yes, but I hope not significantly. I lean toward suggesting "never use |
That seems like sane guidance to me, after reading the previous threads. Props/Targets ordering is hard, and using the functions ensures consistency in a much easier way. It definitely seems like something that should be documented on the existing Best Practices or Customize your Build sections, and something that we should incorporate into the guidance/task examples that we're working on. |
Unfortunately the intrinsic function is quite verbose
and it shows up as expensive in my
@rainersigwald do you know if it's possible to turn that legacy behavior off for .NETStandard and .NETFramework tfms? The internal property exists |
Disabled the default windows platform via the |
We didn't want to change the default target platform of Windows for all projects that targeted existing frameworks, as that would likely break some of them. But for your own projects it should be safe to set I typically use |
Thanks for clarifying. Would you accept a PR that makes the |
The verbosity isn't great, but I may have some ideas about speeding things up. What are you running profileevaluation on specifically? I would like to poke at it. |
Based on @terrajobst's proposal which was implemented with .NET 5, I see a behavior difference when calling the
GetTargetPlatformIdentifier('$(TargetFramework)')
function or when using the$(TargetPlatformIdentifier)
property:Reason for that is that msbuild defaults the
$(TargetPlatformIdentifier)
property to "windows" for any tfm older than net5.0 (.NETFramework, .NETStandard, .NETCoreApp <= 3.1):msbuild/src/Tasks/Microsoft.Common.CurrentVersion.targets
Line 90 in de1d7a2
TargetPlatformIdentifier
(via the_EnableDefaultWindowsPlatform
property) or does nuget/msbuild heavily rely on it being set? Asking for .NETStandard and .NETFramework tfms which based on their alias representation (net48
andnetstandard2.0
vsnet5.0-windows
) don't include a platform.GetTargetPlatformIdentifier
intrinsic function or use theTargetPlatformIdentifier
property instead? In large projects with different platforms like in dotnet/runtime, would multipleGetTargetPlatformIdentifier
invocations slow down the project's evaluation performance?GetTargetPlatformIdentifier
function must be called as theTargetPlatformIdentifier
property isn't available at that time. Isn't it super confusing that ienet48
returns an empty result when calling the function but "windows" when reading form theTargetPlatformIdentifier
property either from an item or from a property inside a target file?I'm posting this as I stumbled upon this behavior difference while working on dotnet/runtime#64500. I'm unsure how to explain to devs on the team why .NETStandard and .NETFramework tfms sometimes have a "windows" platform (when using the TPI property) and sometimes not (when using the TPI function).
@terrajobst @rainersigwald
EDIT:
As an additional note, such a behavior difference is not observable when invoking the
GetTargetFrameworkIdentifier
function and reading from theTargetFrameworkIdentifier
property.The text was updated successfully, but these errors were encountered: