From 0cd324beae7606a5c65655573dce73718027423e Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 22 May 2025 12:20:06 +0000
Subject: [PATCH 1/9] Initial plan for issue
From 3aff8dbeef1f84a5c646dcf6a02443e17dda6c41 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 23 May 2025 08:54:05 +0000
Subject: [PATCH 2/9] Implement GenerateILLinkSubstitutions task for F#
metadata trimming
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
---
src/FSharp.Build/FSharp.Build.fsproj | 1 +
.../GenerateILLinkSubstitutions.fs | 94 +++++++++++++++++++
.../Microsoft.FSharp.NetSdk.targets | 12 +++
3 files changed, 107 insertions(+)
create mode 100644 src/FSharp.Build/GenerateILLinkSubstitutions.fs
diff --git a/src/FSharp.Build/FSharp.Build.fsproj b/src/FSharp.Build/FSharp.Build.fsproj
index 8f2fd4f5951..080c53399b1 100644
--- a/src/FSharp.Build/FSharp.Build.fsproj
+++ b/src/FSharp.Build/FSharp.Build.fsproj
@@ -46,6 +46,7 @@
+
diff --git a/src/FSharp.Build/GenerateILLinkSubstitutions.fs b/src/FSharp.Build/GenerateILLinkSubstitutions.fs
new file mode 100644
index 00000000000..77ab08a5d69
--- /dev/null
+++ b/src/FSharp.Build/GenerateILLinkSubstitutions.fs
@@ -0,0 +1,94 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace FSharp.Build
+
+open System
+open System.IO
+open System.Text
+open Microsoft.Build.Framework
+open Microsoft.Build.Utilities
+
+///
+/// MSBuild task that generates ILLink.Substitutions.xml file to remove F# metadata resources during IL linking.
+///
+type GenerateILLinkSubstitutions() =
+ inherit Task()
+
+ let mutable _assemblyName = ""
+ let mutable _intermediateOutputPath = ""
+ let mutable _generatedItems: ITaskItem[] = [||]
+
+ ///
+ /// Assembly name to use when generating resource names to be removed.
+ ///
+ []
+ member _.AssemblyName
+ with get () = _assemblyName
+ and set value = _assemblyName <- value
+
+ ///
+ /// Intermediate output path for storing the generated file.
+ ///
+ []
+ member _.IntermediateOutputPath
+ with get () = _intermediateOutputPath
+ and set value = _intermediateOutputPath <- value
+
+ ///
+ /// Generated embedded resource items.
+ ///
+ [