Adding condition for default TargetPlatform properties#5391
Adding condition for default TargetPlatform properties#5391rainersigwald merged 1 commit intodotnet:masterfrom
Conversation
| <TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == '' and '$(_EnableDefaultWindowsPlatform)' != 'false'">7.0</TargetPlatformVersion> | ||
| <TargetPlatformSdkPath Condition="'$(TargetPlatformSdkPath)' == '' and '$(TargetPlatformSdkRootOverride)' != ''">$(TargetPlatformSdkRootOverride)\</TargetPlatformSdkPath> | ||
| <TargetPlatformSdkPath Condition="'$(TargetPlatformSdkPath)' == '' and '$(TargetPlatformIdentifier)' == 'Windows' and '$(OS)' == 'Windows_NT' and '$(MSBuildRuntimeType)' != 'Core'">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SDKs\Windows\v$(TargetPlatformVersion)', InstallationFolder, null, RegistryView.Registry32, RegistryView.Default))</TargetPlatformSdkPath> | ||
| <TargetPlatformSdkPath Condition="'$(TargetPlatformSdkPath)' == ''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformSDKLocation($(TargetPlatformIdentifier), $(TargetPlatformVersion)))</TargetPlatformSdkPath> |
There was a problem hiding this comment.
Will GetPlatformSDKLocation and GetPlatformSDKDisplayName (on line 100) handle empty parameters correctly? Did you do a smoke test that you can still build .NET core projects with these changes and _EnableDefaultWindowsPlatform set to false?
There was a problem hiding this comment.
We may want/need to disable setting UseOSWinMdReferences on line 97. We won't be using WinMDs at all on .NET Core.
There was a problem hiding this comment.
Yes, TargetPlatformDisplayName just defaults to an empty string and I'm able to build a .NET core console app.
Would you suggest using the same property (_EnableDefaultWindowsPlatform) to disable UseOSWinMdReferences?
There was a problem hiding this comment.
Actually, I think we should probably just set UseOSWinMdReferences to false in the .NET SDK (possibly conditioned on .NET 5 or higher).
|
I'd also be interested in hearing if @rainersigwald has a better suggestion for the name than |
| <TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == '' and '$(_EnableDefaultWindowsPlatform)' != 'false'">7.0</TargetPlatformVersion> | ||
| <TargetPlatformSdkPath Condition="'$(TargetPlatformSdkPath)' == '' and '$(TargetPlatformSdkRootOverride)' != ''">$(TargetPlatformSdkRootOverride)\</TargetPlatformSdkPath> | ||
| <TargetPlatformSdkPath Condition="'$(TargetPlatformSdkPath)' == '' and '$(TargetPlatformIdentifier)' == 'Windows' and '$(OS)' == 'Windows_NT' and '$(MSBuildRuntimeType)' != 'Core'">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SDKs\Windows\v$(TargetPlatformVersion)', InstallationFolder, null, RegistryView.Registry32, RegistryView.Default))</TargetPlatformSdkPath> | ||
| <TargetPlatformSdkPath Condition="'$(TargetPlatformSdkPath)' == ''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformSDKLocation($(TargetPlatformIdentifier), $(TargetPlatformVersion)))</TargetPlatformSdkPath> |
There was a problem hiding this comment.
Actually, I think we should probably just set UseOSWinMdReferences to false in the .NET SDK (possibly conditioned on .NET 5 or higher).
|
I think you could drop the underscore and make this "public", but I don't feel super strongly about it. My biggest concern is unintended consequences. Can you diff the evaluated properties with and without this set (and no other changes) and see if there are any interesting knock-on effects? |
|
@rainersigwald sure, here's the diff when building a console app: With defaults: Without defaults (
|
rainersigwald
left a comment
There was a problem hiding this comment.
That diff sounds reasonable. I'll leave the underscore to your discretion.
|
@dsplaisted do you have strong feelings on dropping or keeping the underscore? |
No, I don't feel strongly. Personally, I would keep it. |
|
@sfoslund @rainersigwald @zivkan The I have recently encountered both NuGet/Home#10423 and The code paths that are affected by this empty moniker value are in NuGet's parsing logic... Either we should fix the parsing logic to account for empty versions or we should make sure I can do a PR but I need consensus from the MSBuild/NuGet/SDK teams. |
|
Sorry for replying to a one year old PR but what was the reasoning for adding a default TargetPlatformIdentifier i.e. to netstandard2.0? |
Adding a condition for setting default TargetPlatform properties.
_EnableDefaultWindowsPlatformwill be set from the SDK in a separate PR