Trimmed assemblies should not contain sig and opt data
Is your feature request related to a problem? Please describe.
F# assemblies in a trimmed application contain signature and optimization data.
Describe the solution you'd like
These resources serve no purpose in a deployed application and should be stripped.
Describe alternatives you've considered
A post-build task that iterates over and modifies the emitted assemblies.
Additional context
8.0.100-preview.6.23330.14
I don't think we want to be tied to specifics of trimming tasks implementation in FSharp.Build, what we can theoretically do, is generate the ILLink.Substitutions.xml file, however this can become very tricky very soon, if user wants a custom one.
So we probably want to:
a. Generate default ILLink.Substituions.xml
b. A way for user to opt-out, if they want a custom one.
@kerams does this sound feasible?
No clue, I know little about the trimming infrastructure.
In case anyone needs this, here's a snippet that removes the aforementioned resources on all F# assemblies using Mono.Cecil. Run it once trimming has completed.
for f in Directory.EnumerateFiles (serverDir, "*.dll") do
use m = ModuleDefinition.ReadModule (f, ReaderParameters (ReadWrite = true))
let toRemove =
m.Resources
|> Seq.filter (fun x -> x.Name.StartsWith "FSharpSignature" || x.Name.StartsWith "FSharpOptimization")
|> Seq.toList
if not toRemove.IsEmpty then
for res in toRemove do
m.Resources.Remove res |> ignore
m.Write ()
In case anyone needs this, here's a snippet that removes the aforementioned resources on all F# assemblies using Mono.Cecil. Run it once trimming has completed.
for f in Directory.EnumerateFiles (serverDir, "*.dll") do use m = ModuleDefinition.ReadModule (f, ReaderParameters (ReadWrite = true)) let toRemove = m.Resources |> Seq.filter (fun x -> x.Name.StartsWith "FSharpSignature" || x.Name.StartsWith "FSharpOptimization") |> Seq.toList if not toRemove.IsEmpty then for res in toRemove do m.Resources.Remove res |> ignore m.Write ()
It is not needed, just create the xml file for your library, illink will trim it.
For every single referenced assembly, every time I add a new one? I don't think so :).
For every single referenced assembly, every time I add a new one? I don't think so :).
For your assemblies, if you want trimming to be supported. We don't want to be trimming resources from anyone else's assemblies for sure.
I don't see why I would ever want to retain signature and optimization data when publishing, regardless of where an assembly comes from, or even if it is actually being trimmed. Feel free to close - I can just use that script.
I will fix it, it is a bug not a feature request.