Skip to content

Commit e5b2061

Browse files
authored
[msbuild] Ship the net10.0 version of our msbuild tasks. (#24546)
* Ship the net10.0 version of our msbuild tasks. * This required a bit of a reshuffling of the files in our Sdk pack, since we now ship both a netstandard2.0 and a net10.0 version of our msbuild tasks. * Use the net10.0 version of the msbuild tasks by default, but allow opt-out using the property '_UseDesktopTaskAssemblies'. Loading the net10.0 version of the tasks should work in VS2026, because VS2026 supports the "Runtime=NET" metadata on the 'UsingTask' directive (VS2022 does not, but this doesn't matter, because we don't support VS2022 anymore in .NET 10+). Hopefully we'll be able to remove the opt-out once we've confirmed nothing breaks, and then we can remove the netstandard2.0 versions of our task assemblies.
1 parent fd5ac0d commit e5b2061

13 files changed

Lines changed: 146 additions & 133 deletions

dotnet/Microsoft.iOS.Sdk/targets/Microsoft.iOS.Sdk.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<_PlatformName>iOS</_PlatformName>
55
<_PlatformRidNoArch>ios</_PlatformRidNoArch>
66
<!-- Used by Microsoft.iOS.Windows.Sdk -->
7-
<CoreiOSSdkDirectory>$(MSBuildThisFileDirectory)..\tools\msbuild\</CoreiOSSdkDirectory>
7+
<CoreiOSSdkDirectory Condition="'$(_UseDesktopTaskAssemblies)' != 'true'">$(MSBuildThisFileDirectory)..\tools\msbuild\net$(BundledNETCoreAppTargetFrameworkVersion)\</CoreiOSSdkDirectory>
8+
<CoreiOSSdkDirectory Condition="'$(_UseDesktopTaskAssemblies)' == 'true'">$(MSBuildThisFileDirectory)..\tools\msbuild\netstandard2.0\</CoreiOSSdkDirectory>
89
</PropertyGroup>
910

1011
<Import Project="Xamarin.Shared.Sdk.props" Condition="'$(_IsWorkloadEol)' != 'true'" />

dotnet/targets/Microsoft.MaciOS.Sdk.Xcode.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This file contains MSBuild targets that support building Xcode framework project
99

1010
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1111

12-
<UsingTask TaskName="Xamarin.MacDev.Tasks.CreateXcArchive" AssemblyFile="$(_XamarinTaskAssembly)"/>
13-
<UsingTask TaskName="Xamarin.MacDev.Tasks.CreateXcFramework" AssemblyFile="$(_XamarinTaskAssembly)"/>
12+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.CreateXcArchive" AssemblyFile="$(_TaskAssemblyName)"/>
13+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.CreateXcFramework" AssemblyFile="$(_TaskAssemblyName)"/>
1414

1515
<PropertyGroup>
1616
<_XcodeProjectDefaultOutputPathRoot>$(IntermediateOutputPath)xcode/</_XcodeProjectDefaultOutputPathRoot>

dotnet/targets/Xamarin.Shared.Sdk.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<_XamarinRelativeSdkRootDirectory Condition="'$(_XamarinRelativeSdkRootDirectory)' == ''">$(XamarinRelativeSdkRootDirectory)</_XamarinRelativeSdkRootDirectory>
3030
<!-- This is the location of the Microsoft.<platform>.Sdk NuGet on macOS, this value will be overriden from Windows -->
3131
<_XamarinSdkRootDirectoryOnMac>$(_XamarinSdkRootDirectory)</_XamarinSdkRootDirectoryOnMac>
32-
<_XamarinTaskAssembly>$(_XamarinSdkRootDirectory)\tools\msbuild\Xamarin.MacDev.Tasks.dll</_XamarinTaskAssembly>
3332

3433
<!--
3534
PublishAot should only take effect when doing 'dotnet publish', not when doing 'dotnet build'. We distinguish these cases using the '_IsPublishing' property,

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@
77
<Version Condition="'$(GenerateApplicationManifest)' == 'true' and '$(ApplicationDisplayVersion)' != ''">$(ApplicationDisplayVersion)</Version>
88
</PropertyGroup>
99

10-
<UsingTask TaskName="Xamarin.MacDev.Tasks.CompileNativeCode" AssemblyFile="$(_XamarinTaskAssembly)" />
11-
<UsingTask TaskName="Xamarin.MacDev.Tasks.FindAotCompiler" AssemblyFile="$(_XamarinTaskAssembly)" />
12-
<UsingTask TaskName="Xamarin.MacDev.Tasks.GetFullPaths" AssemblyFile="$(_XamarinTaskAssembly)" />
13-
<UsingTask TaskName="Xamarin.MacDev.Tasks.InstallNameTool" AssemblyFile="$(_XamarinTaskAssembly)" />
14-
<UsingTask TaskName="Xamarin.MacDev.Tasks.LinkNativeCode" AssemblyFile="$(_XamarinTaskAssembly)" />
15-
<UsingTask TaskName="Xamarin.MacDev.Tasks.MergeAppBundles" AssemblyFile="$(_XamarinTaskAssembly)" />
16-
<UsingTask TaskName="Xamarin.MacDev.Tasks.MobileILStrip" AssemblyFile="$(_XamarinTaskAssembly)" />
17-
<UsingTask TaskName="Xamarin.MacDev.Tasks.MacDevMessage" AssemblyFile="$(_XamarinTaskAssembly)" />
10+
<PropertyGroup Condition="'$(_TaskAssemblyName)' == ''">
11+
<_TaskAssemblyFileName>Xamarin.MacDev.Tasks.dll</_TaskAssemblyFileName>
12+
<_TaskAssemblyFileNameWindows>Xamarin.iOS.Tasks.Windows.dll</_TaskAssemblyFileNameWindows>
13+
<_TaskAssemblyRootDirectory>$(MSBuildThisFileDirectory)\..\tools\msbuild\</_TaskAssemblyRootDirectory>
14+
<_TaskAssemblyName Condition="'$(_UseDesktopTaskAssemblies)' != 'true'">$(_TaskAssemblyRootDirectory)net$(BundledNETCoreAppTargetFrameworkVersion)\$(_TaskAssemblyFileName)</_TaskAssemblyName>
15+
<_TaskAssemblyName Condition="'$(_UseDesktopTaskAssemblies)' == 'true'">$(_TaskAssemblyRootDirectory)netstandard2.0\$(_TaskAssemblyFileName)</_TaskAssemblyName>
16+
<_TaskRuntime Condition="'$(_UseDesktopTaskAssemblies)' != 'true'">NET</_TaskRuntime>
17+
<_TaskRuntime Condition="'$(_UseDesktopTaskAssemblies)' == 'true'">CurrentRuntime</_TaskRuntime>
18+
</PropertyGroup>
19+
20+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.CompileNativeCode" AssemblyFile="$(_TaskAssemblyName)" />
21+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.FindAotCompiler" AssemblyFile="$(_TaskAssemblyName)" />
22+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.GetFullPaths" AssemblyFile="$(_TaskAssemblyName)" />
23+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.InstallNameTool" AssemblyFile="$(_TaskAssemblyName)" />
24+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.LinkNativeCode" AssemblyFile="$(_TaskAssemblyName)" />
25+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.MergeAppBundles" AssemblyFile="$(_TaskAssemblyName)" />
26+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.MobileILStrip" AssemblyFile="$(_TaskAssemblyName)" />
27+
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.MacDevMessage" AssemblyFile="$(_TaskAssemblyName)" />
1828

1929
<!-- Project types and how do we distinguish between them
2030

msbuild/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Versions.g.cs
22
.failed-stamp
33
.build-stamp
4+
.copy-stamp-*
45
.stamp-test-xml
56

msbuild/Makefile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ALL_SOURCES:= \
3535

3636
CONFIG = Debug
3737
TARGETFRAMEWORK = netstandard2.0
38+
NETTARGETFRAMEWORK = $(DOTNET_TFM)
3839
WINDOWSRUNTIMEIDENTIFIER = win
3940

4041
LOCALIZATION_LANGUAGES=cs de es fr it ja ko pl pt-BR ru tr zh-Hans zh-Hant
@@ -48,8 +49,8 @@ LOCALIZATION_ASSEMBLIES = Xamarin.Localization.MSBuild
4849
IOS_WINDOWS_TARGETS = \
4950
$(wildcard Xamarin.iOS.Tasks.Windows/Xamarin.*.props) \
5051
$(wildcard Xamarin.iOS.Tasks.Windows/Xamarin.*.targets) \
51-
$(wildcard Xamarin.iOS.Tasks.Windows/bin/$(CONFIG)/$(TARGETFRAMEWORK)/$(WINDOWSRUNTIMEIDENTIFIER)/Xamarin.*.props) \
52-
$(wildcard Xamarin.iOS.Tasks.Windows/bin/$(CONFIG)/$(TARGETFRAMEWORK)/$(WINDOWSRUNTIMEIDENTIFIER)/Xamarin.*.targets) \
52+
$(wildcard Xamarin.iOS.Tasks.Windows/bin/$(CONFIG)/$(NETTARGETFRAMEWORK)/$(WINDOWSRUNTIMEIDENTIFIER)/Xamarin.*.props) \
53+
$(wildcard Xamarin.iOS.Tasks.Windows/bin/$(CONFIG)/$(NETTARGETFRAMEWORK)/$(WINDOWSRUNTIMEIDENTIFIER)/Xamarin.*.targets) \
5354

5455
TASK_ASSEMBLIES = Xamarin.MacDev.Tasks $(LOCALIZATION_ASSEMBLIES)
5556
IOS_WINDOWS_TASK_ASSEMBLIES = Xamarin.iOS.Tasks.Windows
@@ -65,30 +66,37 @@ MSBUILD_TASK_ASSEMBLIES += $(TASK_ASSEMBLIES)
6566
## .NET targets ##
6667
##
6768

68-
DOTNET_SHARED_FILES = \
69-
$(PROPS_AND_TARGETS) \
69+
DOTNET_SHARED_ASSEMBLIES = \
7070
$(foreach dll,$(MSBUILD_TASK_ASSEMBLIES),$(dll).dll $(dll).pdb)
7171

7272
define InstallFiles
7373

7474
DOTNET_TARGETS += \
75-
$(foreach target,$(DOTNET_SHARED_FILES),$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(notdir $(target))) \
76-
$(foreach dll,$(TRANSLATED_ASSEMBLIES),$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(dll).resources.dll) \
75+
$(foreach target,$(PROPS_AND_TARGETS),$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(notdir $(target))) \
76+
$(foreach target,$(DOTNET_SHARED_ASSEMBLIES),$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(TARGETFRAMEWORK)/$(notdir $(target))) \
77+
$(foreach dll,$(TRANSLATED_ASSEMBLIES),$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(TARGETFRAMEWORK)/$(dll).resources.dll) \
78+
.copy-stamp-$(1) \
7779

7880
DOTNET_DIRECTORIES_$(1) += \
7981
$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild \
80-
$(foreach locale,$(LOCALIZATION_LANGUAGES),$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(locale)) \
82+
$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(TARGETFRAMEWORK) \
83+
$(foreach locale,$(LOCALIZATION_LANGUAGES),$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(TARGETFRAMEWORK)/$(locale)) \
8184

8285
DOTNET_DIRECTORIES += $$(DOTNET_DIRECTORIES_$(1))
8386

8487
$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/%: Xamarin.Shared/% | $(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild
8588
$$(Q) install -m 644 $$< $$@
8689

87-
$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/%: Xamarin.MacDev.Tasks/bin/$(CONFIG)/$(TARGETFRAMEWORK)/% | $$(DOTNET_DIRECTORIES_$(1))
90+
$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(TARGETFRAMEWORK)/%: Xamarin.MacDev.Tasks/bin/$(CONFIG)/$(TARGETFRAMEWORK)/% | $$(DOTNET_DIRECTORIES_$(1))
8891
$$(Q) install -m 644 $$< $$@
8992

90-
$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/%: Xamarin.Localization.MSBuild/bin/$(CONFIG)/$(TARGETFRAMEWORK)/% | $$(DOTNET_DIRECTORIES_$(1))
93+
$(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(TARGETFRAMEWORK)/%: Xamarin.Localization.MSBuild/bin/$(CONFIG)/$(TARGETFRAMEWORK)/% | $$(DOTNET_DIRECTORIES_$(1))
9194
$$(Q) install -m 644 $$< $$@
95+
96+
.copy-stamp-$(1): $$(wildcard Xamarin.MacDev.Tasks/bin/$(CONFIG)/$(NETTARGETFRAMEWORK)/*) $$(wildcard Xamarin.MacDev.Tasks/bin/$(CONFIG)/$(NETTARGETFRAMEWORK)/*/*) .build-stamp | $(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild
97+
$$(Q) rm -rf $(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(NETTARGETFRAMEWORK)/
98+
$$(Q) $(CP) -r Xamarin.MacDev.Tasks/bin/$(CONFIG)/$(NETTARGETFRAMEWORK) $(DOTNET_DESTDIR)/$($(2)_NUGET_SDK_NAME)/tools/msbuild/$(NETTARGETFRAMEWORK)
99+
$$(Q) touch $$@
92100
endef
93101

94102
$(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call InstallFiles,$(platform),$(shell echo $(platform) | tr 'a-z' 'A-Z'))))

msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<NoWarn>$(NoWarn);MSB3277</NoWarn> <!-- warning MSB3277: Found conflicts between different versions of "System.Reflection.Metadata" that could not be resolved. -->
1616
<NoWarn>$(NoWarn);8002</NoWarn> <!-- Referenced projects aren't signed: this doesn't matter, because we use ILMerge to merge into a single assembly which we sign -->
1717
<Nullable>enable</Nullable>
18+
<CopyLocalLockFileAssemblies Condition="'$(TargetFramework)' == 'net$(BundledNETCoreAppTargetFrameworkVersion)'">true</CopyLocalLockFileAssemblies>
1819
</PropertyGroup>
1920

2021
<Import Project="..\..\eng\Versions.props" />
@@ -51,7 +52,7 @@
5152
</Reference>
5253
</ItemGroup>
5354

54-
<Import Project="$(MSBuildThisFileDirectory)..\ILMerge.targets" />
55+
<Import Project="$(MSBuildThisFileDirectory)..\ILMerge.targets" Condition="'$(TargetFramework)' != 'net$(BundledNETCoreAppTargetFrameworkVersion)'" />
5556

5657
<Target Name="CopyRuntimeAssemblies" BeforeTargets="ILRepack">
5758
<ItemGroup>

0 commit comments

Comments
 (0)