From 04a3db4d60802fdb99a25381228b9e5b2246dcf8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 10:13:20 -0500 Subject: [PATCH] Remove dead OnlyAndroid method and call sites The OnlyAndroid method in BaseTemplateTests searches for a static TargetFrameworks string that no longer exists in MAUI templates. Since PR #33576 on net11.0, templates use MSBuild conditions to restrict TargetFrameworks to Android-only on Linux, making OnlyAndroid a silent no-op. Removing the method and its 3 call sites: - AOTTemplateTest.PublishNativeAOT - AOTTemplateTest.PublishNativeAOTRootAllMauiAssemblies - SimpleTemplateTest.Build This also prevents merge conflicts when merging main into net11.0, where OnlyAndroid was already removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../AOTTemplateTest.cs | 12 ------------ .../BaseTemplateTests.cs | 8 -------- .../SimpleTemplateTest.cs | 6 ------ 3 files changed, 26 deletions(-) diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/AOTTemplateTest.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/AOTTemplateTest.cs index 8ded0f18f133..7858ec9b8491 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/AOTTemplateTest.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/AOTTemplateTest.cs @@ -34,12 +34,6 @@ public void PublishNativeAOT(string id, string framework, string runtimeIdentifi Assert.True(DotnetInternal.New(id, projectDir, DotNetCurrent, output: _output), $"Unable to create template {id}. Check test output for errors."); - // For Android-only builds on Linux, modify the csproj to only target Android - // This avoids restore failures due to missing iOS/macCatalyst workloads - if (isAndroidPlatform && !TestEnvironment.IsMacOS && !TestEnvironment.IsWindows) - { - OnlyAndroid(projectFile); - } var extendedBuildProps = isWindowsFramework ? PrepareNativeAotBuildPropsWindows(runtimeIdentifier) @@ -95,12 +89,6 @@ public void PublishNativeAOTRootAllMauiAssemblies(string id, string framework, s Assert.True(DotnetInternal.New(id, projectDir, DotNetCurrent, output: _output), $"Unable to create template {id}. Check test output for errors."); - // For Android-only builds on Linux, modify the csproj to only target Android - // This avoids restore failures due to missing iOS/macCatalyst workloads - if (isAndroidPlatform && !TestEnvironment.IsMacOS && !TestEnvironment.IsWindows) - { - OnlyAndroid(projectFile); - } var extendedBuildProps = isWindowsFramework ? PrepareNativeAotBuildPropsWindows(runtimeIdentifier) diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/BaseTemplateTests.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/BaseTemplateTests.cs index 1a73d119a0a1..88f9ea35e034 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/BaseTemplateTests.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/BaseTemplateTests.cs @@ -11,14 +11,6 @@ protected BaseTemplateTests(IntegrationTestFixture fixture, ITestOutputHelper ou Path.Combine(TestDirectory, "Directory.Build.targets"), true); } - protected void OnlyAndroid(string projectFile) - { - FileUtilities.ReplaceInFile(projectFile, new Dictionary() - { - { "net10.0-android;net10.0-ios;net10.0-maccatalyst", "net10.0-android" }, - }); - } - protected void AssertContains(string expected, string actual) { Assert.True( diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/SimpleTemplateTest.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/SimpleTemplateTest.cs index a79ca922cb88..869ddccdb777 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/SimpleTemplateTest.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/SimpleTemplateTest.cs @@ -43,12 +43,6 @@ public void Build(string id, string framework, string config, bool shouldPack, s "", "1.0.0-preview.1"); - // We only have these packs for Android - if (additionalDotNetBuildParams.Contains("UseMonoRuntime=false", StringComparison.OrdinalIgnoreCase)) - { - OnlyAndroid(projectFile); - } - var buildProps = BuildProps; if (additionalDotNetBuildParams is not "" and not null)