Skip to content

Commit

Permalink
[workload] Update net6.0 KnownFrameworkReference (dotnet#15834)
Browse files Browse the repository at this point in the history
A `Xamarin.Shared.Sdk.MultiTarget.targets` file has been added to update
the ref/runtime pack versions associated with the .NET 6 SDK.  This file
will ship as part of the .NET 7 SDK but only be imported when using the
.NET 6 SDK.  This should work around the need to add new and net7
versioned aliases of the `Ref` and `Runtime` packs.  Adding this file to
`AfterMicrosoftNETSdkTargets` will ensure that it is imported last,
after all `KnownFrameworkReferences` that need updating are declared.
  • Loading branch information
pjcollins authored Sep 1, 2022
1 parent 7eb5ebb commit 53766eb
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 24 deletions.
2 changes: 2 additions & 0 deletions dotnet/.gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
tmpdir
Workloads/Microsoft.NET.Sdk.*/LICENSE
WorkloadManifest.json
WorkloadManifest.targets
nupkgs
Microsoft.*.Sdk/targets/Microsoft.*.Sdk.ImplicitNamespaceImports.props
Microsoft.*.Sdk/targets/Microsoft.*.Sdk.SupportedTargetPlatforms.props
Microsoft.*.Sdk/targets/Microsoft.*.Sdk.DefaultItems.props
Microsoft.*.Sdk/targets/Microsoft.*.Sdk.Versions.props
Microsoft.*.Sdk/targets/Xamarin.Shared.Sdk.MultiTarget.targets
Microsoft.*.Sdk/Sdk/AutoImport.props
_pkg
.stamp-*
20 changes: 20 additions & 0 deletions dotnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ $(1)_NUGET_TARGETS = \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Microsoft.$(1).Sdk.Versions.props \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Microsoft.$(1).Sdk.targets \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Xamarin.Shared.Sdk.DefaultItems.targets \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Xamarin.Shared.Sdk.MultiTarget.targets \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Xamarin.Shared.Sdk.Publish.targets \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Xamarin.Shared.Sdk.TargetFrameworkInference.props \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Xamarin.Shared.Sdk.props \
Expand Down Expand Up @@ -154,19 +155,37 @@ Microsoft.$(1).Sdk/targets/Microsoft.$(1).Sdk.SupportedTargetPlatforms.props: $(
endef
$(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call SupportedTargetPlatforms,$(platform))))

define SharedAfterTargetsTemplate
Microsoft.$(1).Sdk/targets/Xamarin.Shared.Sdk.MultiTarget.targets: targets/Xamarin.Shared.Sdk.MultiTarget.template.targets Makefile $(TOP)/Make.config.inc $(TOP)/.git/HEAD $(TOP)/.git/index
$$(Q_GEN) sed \
-e "s/@NET6_NUGET_VERSION_NO_METADATA@/$2/g" \
$$< > $$@.tmp
$$(Q) mv $$@.tmp $$@
endef
$(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call SharedAfterTargetsTemplate,$(platform),$(NET6_$(platform)_NUGET_VERSION_NO_METADATA))))

define WorkloadTargets
Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.json: Makefile $(TOP)/Make.config.inc $(TOP)/.git/HEAD $(TOP)/.git/index Makefile generate-workloadmanifest-json.csharp
$$(Q) mkdir -p Workloads/Microsoft.NET.Sdk.$(1)/
$$(Q) rm -f $$@.tmp
$$(Q_GEN) ./generate-workloadmanifest-json.csharp "$(1)" "$(3)" "$(4)" "$$(DOTNET_$(5)_RUNTIME_IDENTIFIERS)" "$$@.tmp" "$$(DOTNET_WINDOWS_PLATFORMS)"
$$(Q) mv $$@.tmp $$@

Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.targets: Workloads/WorkloadManifest.$(1).template.targets Makefile $(TOP)/Make.config.inc $(TOP)/.git/HEAD $(TOP)/.git/index
$$(Q_GEN) sed \
-e "s/@NUGET_VERSION_NO_METADATA@/$3/g" \
$$< > $$@.tmp
$$(Q) mv $$@.tmp $$@

Workloads/Microsoft.NET.Sdk.$(1)/LICENSE: $(TOP)/LICENSE
$$(Q) $(CP) $$< $$@

WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.json
WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.targets
WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/LICENSE

LOCAL_WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.json
LOCAL_WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.targets
LOCAL_WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/LICENSE
endef
$(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call WorkloadTargets,$(platform),$(shell echo $(platform) | tr A-Z a-z),$($(platform)_NUGET_VERSION_NO_METADATA),$(NET6_$(platform)_NUGET_VERSION_NO_METADATA),$(shell echo $(platform) | tr a-z A-Z))))
Expand All @@ -192,6 +211,7 @@ $(DOTNET_NUPKG_DIR)/SignList.targets: Workloads/SignList.targets
TEMPLATED_FILES = \
$(foreach platform,$(DOTNET_PLATFORMS),Microsoft.$(platform).Sdk/targets/Microsoft.$(platform).Sdk.Versions.props) \
$(foreach platform,$(DOTNET_PLATFORMS),Microsoft.$(platform).Sdk/targets/Microsoft.$(platform).Sdk.SupportedTargetPlatforms.props) \
$(foreach platform,$(DOTNET_PLATFORMS),Microsoft.$(platform).Sdk/targets/Xamarin.Shared.Sdk.MultiTarget.targets) \

nupkgs/$(IOS_WINDOWS_NUGET).%.nupkg: CURRENT_VERSION_NO_METADATA=$(IOS_WINDOWS_NUGET_VERSION_NO_METADATA)
nupkgs/$(IOS_WINDOWS_NUGET).%.nupkg: CURRENT_VERSION_FULL=$(IOS_WINDOWS_NUGET_VERSION_FULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) ">
<SdkSupportedTargetPlatformIdentifier Include="maccatalyst" DisplayName="Mac Catalyst" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == 'MacCatalyst' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(_XamarinSdkRootDirectory)..\@NUGET_VERSION_NO_METADATA@\targets\Xamarin.Shared.Sdk.MultiTarget.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) ">
<SdkSupportedTargetPlatformIdentifier Include="ios" DisplayName="iOS" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == 'iOS' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(_XamarinSdkRootDirectory)..\@NUGET_VERSION_NO_METADATA@\targets\Xamarin.Shared.Sdk.MultiTarget.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) ">
<SdkSupportedTargetPlatformIdentifier Include="macos" DisplayName="macOS" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == 'macOS' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(_XamarinSdkRootDirectory)..\@NUGET_VERSION_NO_METADATA@\targets\Xamarin.Shared.Sdk.MultiTarget.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) ">
<SdkSupportedTargetPlatformIdentifier Include="tvos" DisplayName="tvOS" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == 'tvOS' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(_XamarinSdkRootDirectory)..\@NUGET_VERSION_NO_METADATA@\targets\Xamarin.Shared.Sdk.MultiTarget.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>
</Project>
23 changes: 2 additions & 21 deletions dotnet/generate-workloadmanifest-json.csharp
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,14 @@ using (TextWriter writer = new StreamWriter (outputPath)) {
writer.WriteLine ($" }}");
writer.WriteLine ($" }},");
}
writer.WriteLine ($" // The ref and runtime packs use the .net6 version, because when we load the .net6 SDK pack, it says to use the ref and runtime pack versions from the workload (**FromWorkload**).");
writer.WriteLine ($" // This could be solvable with aliases as well, except that aliases doesn't work in this scenario (https://github.com/dotnet/sdk/issues/26384).");
writer.WriteLine ($" // For the .net7 packs, we're stating the exact version to use in the KnownFrameworkReference item, so whatever we specify here is ignored.");
writer.WriteLine ($" \"Microsoft.{platform}.Ref\": {{");
writer.WriteLine ($" \"kind\": \"framework\",");
writer.WriteLine ($" \"version\": \"{net6Version}\"");
writer.WriteLine ($" }},");
writer.WriteLine ($" \"Microsoft.{platform}.Ref.net7\": {{");
writer.WriteLine ($" \"kind\": \"framework\",");
writer.WriteLine ($" \"version\": \"{version}\",");
writer.WriteLine ($" \"alias-to\": {{");
writer.WriteLine ($" \"any\": \"Microsoft.{platform}.Ref\",");
writer.WriteLine ($" }}");
writer.WriteLine ($" \"version\": \"{version}\"");
writer.WriteLine ($" }},");
foreach (var rid in runtimeIdentifiers) {
writer.WriteLine ($" \"Microsoft.{platform}.Runtime.{rid}\": {{");
writer.WriteLine ($" \"kind\": \"framework\",");
writer.WriteLine ($" \"version\": \"{net6Version}\"");
writer.WriteLine ($" }},");
}
foreach (var rid in runtimeIdentifiers) {
writer.WriteLine ($" \"Microsoft.{platform}.Runtime.{rid}.net7\": {{");
writer.WriteLine ($" \"kind\": \"framework\",");
writer.WriteLine ($" \"version\": \"{version}\",");
writer.WriteLine ($" \"alias-to\": {{");
writer.WriteLine ($" \"any\": \"Microsoft.{platform}.Runtime.{rid}\",");
writer.WriteLine ($" }}");
writer.WriteLine ($" \"version\": \"{version}\"");
writer.WriteLine ($" }},");
}
writer.WriteLine ($" \"Microsoft.{platform}.Templates.net7\": {{");
Expand Down
6 changes: 3 additions & 3 deletions dotnet/targets/Microsoft.Sdk.Versions.template.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
Include="Microsoft.@PLATFORM@"
TargetFramework="@DOTNET_TFM@"
RuntimeFrameworkName="Microsoft.@PLATFORM@"
DefaultRuntimeFrameworkVersion="@NUGET_VERSION_NO_METADATA@"
LatestRuntimeFrameworkVersion="@NUGET_VERSION_NO_METADATA@"
DefaultRuntimeFrameworkVersion="**FromWorkload**"
LatestRuntimeFrameworkVersion="**FromWorkload**"
TargetingPackName="Microsoft.@PLATFORM@.Ref"
TargetingPackVersion="@NUGET_VERSION_NO_METADATA@"
TargetingPackVersion="**FromWorkload**"
RuntimePackNamePatterns="Microsoft.@PLATFORM@.Runtime.**RID**"
RuntimePackRuntimeIdentifiers="@RUNTIME_PACK_RUNTIME_IDENTIFIERS@"
Profile="@PLATFORM@"
Expand Down
11 changes: 11 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.MultiTarget.template.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == '$(_PlatformName)' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
<KnownFrameworkReference
Update="Microsoft.$(_PlatformName)"
DefaultRuntimeFrameworkVersion="@NET6_NUGET_VERSION_NO_METADATA@"
LatestRuntimeFrameworkVersion="@NET6_NUGET_VERSION_NO_METADATA@"
TargetingPackVersion="@NET6_NUGET_VERSION_NO_METADATA@"
/>
</ItemGroup>
</Project>

0 comments on commit 53766eb

Please sign in to comment.