diff --git a/dotnet/Makefile b/dotnet/Makefile index 06ed12c0aa80..ed4d54d4cf6d 100644 --- a/dotnet/Makefile +++ b/dotnet/Makefile @@ -37,6 +37,7 @@ $(1)_NUGET_TARGETS = \ $(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/targets/Xamarin.Shared.Sdk.Publish.targets \ $(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/targets/Xamarin.Shared.Sdk.TargetFrameworkInference.props \ $(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/targets/Xamarin.Shared.Sdk.props \ + $(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/targets/Xamarin.Shared.Sdk.Trimming.props \ $(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/targets/Xamarin.Shared.Sdk.targets \ endef diff --git a/dotnet/targets/Xamarin.Shared.Sdk.Trimming.props b/dotnet/targets/Xamarin.Shared.Sdk.Trimming.props new file mode 100644 index 000000000000..b8f615294e1d --- /dev/null +++ b/dotnet/targets/Xamarin.Shared.Sdk.Trimming.props @@ -0,0 +1,73 @@ + + + + + + + + + <_DefaultLinkMode>TrimMode + + + + <_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true'">Full + + <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'macOS'">None + <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' == 'Release'">SdkOnly + <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' != 'Release'">None + <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst' And '$(_SdkIsSimulator)' == 'true'">None + <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst' And '$(_SdkIsSimulator)' != 'true'">SdkOnly + + + <_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' == 'macOS'">$(LinkMode) + <_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' != 'macOS'">$(MtouchLink) + <_LinkMode Condition="'$(_LinkMode)' == ''">$(_DefaultLinkMode) + <_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' == 'macOS'">None + <_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' != 'macOS'">SdkOnly + + + $(TrimMode) + copy + partial + full + + + diff --git a/dotnet/targets/Xamarin.Shared.Sdk.props b/dotnet/targets/Xamarin.Shared.Sdk.props index e2c40248b2b2..1c9cd8b75698 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.props +++ b/dotnet/targets/Xamarin.Shared.Sdk.props @@ -143,34 +143,9 @@ <_SdkIsSimulator Condition="'$(_SdkIsSimulator)' == ''">false - - - - <_DefaultLinkMode>TrimMode - - - - <_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true'">Full - - <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'macOS'">None - <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' == 'Release'">SdkOnly - <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' != 'Release'">None - <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst' And '$(_SdkIsSimulator)' == 'true'">None - <_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst' And '$(_SdkIsSimulator)' != 'true'">SdkOnly - - <_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' == 'macOS'">$(LinkMode) - <_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' != 'macOS'">$(MtouchLink) - <_LinkMode Condition="'$(_LinkMode)' == ''">$(_DefaultLinkMode) - <_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' == 'macOS'">None - <_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' != 'macOS'">SdkOnly - - - $(TrimMode) - copy - partial - full - + + $(CustomAfterDirectoryBuildTargets);$(MSBuildThisFileDirectory)Xamarin.Shared.Sdk.Trimming.props diff --git a/tests/common/DotNet.cs b/tests/common/DotNet.cs index beaeaee24127..15be67b95b77 100644 --- a/tests/common/DotNet.cs +++ b/tests/common/DotNet.cs @@ -113,6 +113,33 @@ public static ExecutionResult AssertNew (string outputDirectory, string template return new ExecutionResult (output, output, rv.ExitCode); } + public static ExecutionResult InstallWorkload (params string [] workloads) + { + var args = new List (); + args.Add ("workload"); + args.Add ("install"); + args.AddRange (workloads); + args.Add ("-v"); + args.Add ("diag"); + args.Add ("--skip-manifest-update"); + + var env = new Dictionary (); + env ["MSBuildSDKsPath"] = null; + env ["MSBUILD_EXE_PATH"] = null; + + var output = new StringBuilder (); + var rv = Execution.RunWithStringBuildersAsync (Executable, args, env, output, output, Console.Out, workingDirectory: Configuration.SourceRoot, timeout: TimeSpan.FromMinutes (10)).Result; + if (rv.ExitCode != 0) { + var msg = new StringBuilder (); + msg.AppendLine ($"'dotnet workload install' failed with exit code {rv.ExitCode}"); + msg.AppendLine ($"Full command: {Executable} {StringUtils.FormatArguments (args)}"); + msg.AppendLine (output.ToString ()); + Console.WriteLine (msg); + Assert.Fail (msg.ToString ()); + } + return new ExecutionResult (output, output, rv.ExitCode); + } + public static ExecutionResult InstallTool (string tool, string path) { var installed = ExecuteCommand (Executable, "tool", "list", "--tool-path", path); diff --git a/tests/dotnet/MyMauiApp/MacCatalyst/App.xaml b/tests/dotnet/MyMauiApp/MacCatalyst/App.xaml new file mode 100644 index 000000000000..00ed359e7842 --- /dev/null +++ b/tests/dotnet/MyMauiApp/MacCatalyst/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/tests/dotnet/MyMauiApp/MacCatalyst/App.xaml.cs b/tests/dotnet/MyMauiApp/MacCatalyst/App.xaml.cs new file mode 100644 index 000000000000..525041dbe4ac --- /dev/null +++ b/tests/dotnet/MyMauiApp/MacCatalyst/App.xaml.cs @@ -0,0 +1,10 @@ +namespace MyMauiApp; + +public partial class App : Application { + public App () + { + InitializeComponent (); + + MainPage = new AppShell (); + } +} diff --git a/tests/dotnet/MyMauiApp/MacCatalyst/AppShell.xaml b/tests/dotnet/MyMauiApp/MacCatalyst/AppShell.xaml new file mode 100644 index 000000000000..6b57decd788a --- /dev/null +++ b/tests/dotnet/MyMauiApp/MacCatalyst/AppShell.xaml @@ -0,0 +1,15 @@ + + + + + + diff --git a/tests/dotnet/MyMauiApp/MacCatalyst/AppShell.xaml.cs b/tests/dotnet/MyMauiApp/MacCatalyst/AppShell.xaml.cs new file mode 100644 index 000000000000..275a63c55d45 --- /dev/null +++ b/tests/dotnet/MyMauiApp/MacCatalyst/AppShell.xaml.cs @@ -0,0 +1,8 @@ +namespace MyMauiApp; + +public partial class AppShell : Shell { + public AppShell () + { + InitializeComponent (); + } +} diff --git a/tests/dotnet/MyMauiApp/MacCatalyst/MainPage.xaml b/tests/dotnet/MyMauiApp/MacCatalyst/MainPage.xaml new file mode 100644 index 000000000000..776cf3417da3 --- /dev/null +++ b/tests/dotnet/MyMauiApp/MacCatalyst/MainPage.xaml @@ -0,0 +1,36 @@ + + + + + + + +