Skip to content
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

[dotnet] Use the default .NET scheme for TargetPlatformVersion for library projects. #21343

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Make.versions
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ WATCHOS_NUGET_OS_VERSION=11.0
MACOS_NUGET_OS_VERSION=15.0
MACCATALYST_NUGET_OS_VERSION=18.0

# The following are the OS versions we first supported with the current .NET version.
# These versions must *not* change with minor .NET updates, only major .NET releases.
IOS_TARGET_PLATFORM_VERSION_LIBRARY=18.0
TVOS_TARGET_PLATFORM_VERSION_LIBRARY=18.0
MACOS_TARGET_PLATFORM_VERSION_LIBRARY=15.0
MACCATALYST_TARGET_PLATFORM_VERSION_LIBRARY=18.0

# In theory we should define the default platform version if it's not specified in the TFM. The default should not change for a given .NET version:
# * We release support for iOS 14.5 with .NET 6
Expand Down Expand Up @@ -100,6 +106,14 @@ MACCATALYST_NUGET_OS_VERSION=18.0
# So we've made the decision that the default target platform version is
# always the latest target platform version.

# However, this turns out to be somewhat of a complication for library developers,
# because they typically don't need Xcode to build their projects, and if we auto-
# update their TargetPlatformVersion to the latest, then all their customers
# have to also update their workloads, which for some people end up being a rather
# nasty surprise (because with the above algorithm it happens without developer
# action). Thus we follow .NET's default platform version scheme for library projects:
# it won't change in minor .NET releases.


#
# Here we list all the releases we support for each platform.
Expand Down
3 changes: 2 additions & 1 deletion dotnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ targets/Microsoft.$(1).Sdk.Versions.props: targets/Microsoft.Sdk.Versions.templa
-e "s/@PLATFORM@/$(1)/g" \
-e "s/@NUGET_VERSION_NO_METADATA@/$$($(2)_NUGET_VERSION_NO_METADATA)/g" \
-e "s/@NUGET_VERSION_FULL@/$$($(2)_NUGET_VERSION_FULL)/g" \
-e "s/@TARGET_PLATFORM_VERSION@/$$($(2)_NUGET_OS_VERSION)/g" \
-e "s/@TARGET_PLATFORM_VERSION_EXE@/$$($(2)_NUGET_OS_VERSION)/g" \
-e "s/@TARGET_PLATFORM_VERSION_LIBRARY@/$$($(2)_TARGET_PLATFORM_VERSION_LIBRARY)/g" \
-e "s/@CURRENT_BRANCH@/$$(CURRENT_BRANCH_SED_ESCAPED)/g" \
-e "s/@CURRENT_HASH_LONG@/$$(CURRENT_HASH_LONG)/g" \
-e 's*@VALID_RUNTIME_IDENTIFIERS@*$(foreach rid,$(3),\n\t\t<_XamarinValidRuntimeIdentifier Include="$(rid)" Platform="$(1)" />)*' \
Expand Down
3 changes: 2 additions & 1 deletion dotnet/targets/Microsoft.Sdk.Versions.template.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<_ShortPackageVersion>@NUGET_VERSION_NO_METADATA@</_ShortPackageVersion>
<_PackageVersion>@NUGET_VERSION_FULL@</_PackageVersion>
<_XamarinTargetPlatformVersion>@TARGET_PLATFORM_VERSION@</_XamarinTargetPlatformVersion>
<_XamarinTargetPlatformVersionExecutable>@TARGET_PLATFORM_VERSION_EXE@</_XamarinTargetPlatformVersionExecutable>
<_XamarinTargetPlatformVersionLibrary>@TARGET_PLATFORM_VERSION_LIBRARY@</_XamarinTargetPlatformVersionLibrary>
<_XamarinIsPreviewRelease>@XCODE_IS_PREVIEW@</_XamarinIsPreviewRelease>
<_XamarinDotNetVersion>@DOTNET_TFM@</_XamarinDotNetVersion>
<_XamarinPackSuffix>@DOTNET_TFM@_@NUGET_OS_VERSION@</_XamarinPackSuffix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<!-- Set the default TargetPlatformVersion if it wasn't specified in the TargetFramework variable. This must be set after importing Sdk.targets (in Xamarin.Shared.Sdk.targets) -->
<PropertyGroup>
<TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == ''">$(_XamarinTargetPlatformVersion)</TargetPlatformVersion>
<TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == '' And '$(OutputType)' == 'Exe'">$(_XamarinTargetPlatformVersionExecutable)</TargetPlatformVersion>
<TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == '' And '$(OutputType)' != 'Exe'">$(_XamarinTargetPlatformVersionLibrary)</TargetPlatformVersion>
</PropertyGroup>
</Project>