Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Apply XML Configuration for Removing Specific Attribute Instances in .NET Linker ( NativeAOT ) #101680

Closed
dadavadd opened this issue Apr 29, 2024 · 10 comments

Comments

@dadavadd
Copy link

Hello,

I am working on a .NET project and would like to optimize my assembly by removing specific attribute instances using the .NET linker. I have defined the following XML configuration but need guidance on properly integrating it with the linker in a .NET project:
image

How should this XML be integrated into the .NET project configuration to instruct the linker to remove these attribute instances?

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 29, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

@dadavadd dadavadd changed the title How to Apply XML Configuration for Removing Specific Attribute Instances in .NET Linker How to Apply XML Configuration for Removing Specific Attribute Instances in .NET Linker ( NativeAOT ) Apr 29, 2024
@jkotas jkotas added area-Tools-ILLink .NET linker development as well as trimming analyzers and removed area-Meta labels Apr 29, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@vitek-karas
Copy link
Member

/FYI @LakshanF

@JakeYallop
Copy link
Contributor

I've used something like this before:

  <ItemGroup Condition="'$(PublishTrimmed)' == 'True'">
    <RdXmlFile Include="rd.xml" />
  </ItemGroup>

@JakeYallop
Copy link
Contributor

However, its also worth highlighting - NativeAOT uses a different format to the linker: https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/rd-xml-format.md,

So I'm not sure if the XML file you have currently will actually work with NativeAOT.

@dadavadd
Copy link
Author

I've used something like this before:

  <ItemGroup Condition="'$(PublishTrimmed)' == 'True'">
    <RdXmlFile Include="rd.xml" />
  </ItemGroup>

image

@dadavadd
Copy link
Author

However, its also worth highlighting - NativeAOT uses a different format to the linker: https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/rd-xml-format.md,

So I'm not sure if the XML file you have currently will actually work with NativeAOT.

I inserted before the start of the file and compilation completed successfully.

But this did not reduce the weight of the program.😁

@JakeYallop
Copy link
Contributor

I'll admit, I've not really messed with trimming recently - that snippet was just copied from an old piece of code I had lying around.

WinForms does not officially support Native AOT anyway: dotnet/winforms#4649

@MichalStrehovsky MichalStrehovsky added area-NativeAOT-coreclr and removed area-Tools-ILLink .NET linker development as well as trimming analyzers labels Apr 30, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky
Copy link
Member

The native AOT compiler doesn't have any switches (documented or not) to inject this file into compilation and there are no plans to add one. This file format is only for use within the dotnet/runtime repo.

FWIW there is work in progress to make WinForms trimmable.

@MichalStrehovsky MichalStrehovsky closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

5 participants