From bf6a1f6ace8e1d9adab798fca223d21252814d70 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 1 Jul 2026 15:17:09 -0500 Subject: [PATCH] [xaprepare] Delete redundant Windows JdkInfo.props generator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Windows, xaprepare's Step_GenerateFiles.Windows.cs writes external/Java.Interop/bin/Build$(Configuration)/JdkInfo.props from build-tools/xaprepare/xaprepare/Resources/JdkInfo.Windows.props.in. But this file is immediately overwritten. The PrepareWindows.targets Prepare flow runs, in order: 1. `dotnet xaprepare -a` — writes JdkInfo.props (this code). 2. `MSBuild Xamarin.Android.BootstrapTasks.sln` — does not read JdkInfo.props. 3. `MSBuild src/workloads/workloads.csproj` — does not read JdkInfo.props. 4. `CallTarget PrepareJavaInterop` → `dotnet build -t:Prepare Java.Interop.sln` → external/Java.Interop/build-tools/scripts/Prepare.targets → runs the `JdkInfo` MSBuild task → overwrites JdkInfo.props with its own generated content. Nothing between step 1 and step 4 reads the file, and Java.Interop's Prepare always regenerates it. Now that external/Java.Interop is in-tree, we can safely delete the redundant write. This is the smallest-diff removal: * Delete Step_GenerateFiles.Windows.cs (the AddOSSpecificSteps partial). * Delete Resources/JdkInfo.Windows.props.in. * In Step_GenerateFiles.cs, drop the `partial void AddOSSpecificSteps` declaration and collapse GetFilesToGenerate so `atBuildStart == false` returns null. Ctor surface (atBuildStart, onlyRequired) is unchanged so Scenario_Required.cs is unaffected. * In Scenario_Standard.cs, remove the AddEndSteps override — the only thing it did was schedule the now-empty Step_GenerateFiles(atBuildStart: false). Preserved (future slices will address these): * Get_Configuration_OperatingSystem_props (D1). * OperatingSystems/*.cs and Context.OS.* surface. * PrepareWindows.targets, DotNet.targets, Java.Interop's Prepare.targets. Verification: * dotnet build build-tools/xaprepare/xaprepare/xaprepare.csproj -c Debug → Build succeeded. 0 Warning(s). 0 Error(s). * build.cmd -t:Prepare -c Debug (Windows, cold tree) → succeeds; the file external/Java.Interop/bin/BuildDebug/JdkInfo.props exists. * Compare-Object of the resulting JdkInfo.props before vs after this change → byte-identical (1493 bytes, SHA256 DE59A8061B7657831788FFED7BC1DEECA442E9181605083A4553DE7AC8C003A1), confirming Java.Interop's overwrite is what always ends up on disk. * Grep audit under build-tools/xaprepare/: no remaining references to Step_GenerateFiles.Windows, JdkInfo.Windows.props.in, or AddOSSpecificSteps. Follows previous xaprepare deletion slices #11568, #11580, #11608, #11613, #11631, #11731, #11732, #11733, #11737, #11740, #11760, #11803, #11821, #11825, #11826. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../Resources/JdkInfo.Windows.props.in | 21 ---------- .../xaprepare/Scenarios/Scenario_Standard.cs | 6 --- .../Steps/Step_GenerateFiles.Windows.cs | 39 ------------------- .../xaprepare/Steps/Step_GenerateFiles.cs | 21 +++------- 4 files changed, 5 insertions(+), 82 deletions(-) delete mode 100644 build-tools/xaprepare/xaprepare/Resources/JdkInfo.Windows.props.in delete mode 100644 build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.Windows.cs diff --git a/build-tools/xaprepare/xaprepare/Resources/JdkInfo.Windows.props.in b/build-tools/xaprepare/xaprepare/Resources/JdkInfo.Windows.props.in deleted file mode 100644 index c864935858e..00000000000 --- a/build-tools/xaprepare/xaprepare/Resources/JdkInfo.Windows.props.in +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - @JdkJvmPath@ - - - - - - - - - @java@ - @javac@ - @jar@ - @javahome@ - @dotnet@ - - diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs index 782419551de..69277c926ac 100644 --- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs +++ b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs @@ -19,11 +19,5 @@ protected override void AddSteps (Context context) Steps.Add (new Step_GenerateFiles (atBuildStart: true)); } - - protected override void AddEndSteps (Context context) - { - Steps.Add (new Step_GenerateFiles (atBuildStart: false)); - } - } } diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.Windows.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.Windows.cs deleted file mode 100644 index 79b7fd10db0..00000000000 --- a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.Windows.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; - -namespace Xamarin.Android.Prepare -{ - partial class Step_GenerateFiles - { - partial void AddOSSpecificSteps (Context context, List steps) - { - string? javaSdkDirectory = context.Properties.GetValue ("JavaSdkDirectory"); - if (String.IsNullOrEmpty (javaSdkDirectory)) - javaSdkDirectory = context.OS.JavaHome; - - string jdkJvmPath = Path.Combine (javaSdkDirectory, "jre", "bin", "server", "jvm.dll"); - string jdkIncludePathShared = Path.Combine (javaSdkDirectory, "include"); - string jdkIncludePathOS = Path.Combine (jdkIncludePathShared, "win32"); - - var replacements = new Dictionary (StringComparer.Ordinal) { - { "@JdkJvmPath@", jdkJvmPath }, - { "@JdkIncludePathShared@", jdkIncludePathShared }, - { "@JdkIncludePathOS@", jdkIncludePathOS }, - { "@javac@", context.OS.JavaCPath }, - { "@java@", context.OS.JavaPath }, - { "@jar@", context.OS.JarPath }, - { "@javahome@", context.OS.JavaHome }, - { "@dotnet@", Configurables.Paths.DotNetPreviewTool }, - }; - - var step = new GeneratedPlaceholdersFile ( - replacements, - Path.Combine (Configurables.Paths.BootstrapResourcesDir, "JdkInfo.Windows.props.in"), - Path.Combine (Configurables.Paths.ExternalJavaInteropDir, "bin", $"Build{context.Configuration}", "JdkInfo.props") - ); - - steps.Add (step); - } - } -} diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs index 5d555fdf24d..3de2ab6a911 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs @@ -41,28 +41,17 @@ protected override Task Execute (Context context) List? GetFilesToGenerate (Context context) { - if (atBuildStart) { - if (onlyRequired) { - return null; - } else { - return new List { - Get_Configuration_OperatingSystem_props (context), - }; - } - } + if (!atBuildStart) + return null; if (onlyRequired) return null; - var steps = new List (); - - AddOSSpecificSteps (context, steps); - - return steps; + return new List { + Get_Configuration_OperatingSystem_props (context), + }; } - partial void AddOSSpecificSteps (Context context, List steps); - GeneratedFile Get_Configuration_OperatingSystem_props (Context context) { const string OutputFileName = "Configuration.OperatingSystem.props";