dotnet/runtime

[illink][ios] Explicitly setting `PublishTrimmed=true` changes the default feature switch configuration

Open

#108,269 opened on Sep 26, 2024

View on GitHub
 (11 comments) (1 reaction) (0 assignees)C# (5,445 forks)batch import
area-Tools-ILLinkgood first issueos-ios

Repository metrics

Stars
 (17,886 stars)
PR merge metrics
 (Avg merge 12d 11h) (661 merged PRs in 30d)

Description

Description

As called out in: https://github.com/dotnet/runtime/issues/108108#issuecomment-2375220090 iOS apps built with PublishTrimmed=true set on a project level end up with different set of feature switches configured during the build. For example consider the difference in the input to the trimmer with and without setting the property value explicitly:

--feature Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability false->true
--feature System.ComponentModel.DefaultValueAttribute.IsSupported ->false
--feature System.ComponentModel.Design.IDesignerHost.IsSupported ->false
--feature System.Resources.UseSystemResourceKeys true->false
--feature System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported false->true
--feature System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop ->false

Problem

The problem comes from the order of importing MSBuild targets and property evaluation:

Proposal

We should investigate setting the feature switch defaults (and possibly other trimmer setting) in an MSBuild target so that mobile SDKs can provide different defaults earlier in the build.

Contributor guide