xamarin-macios icon indicating copy to clipboard operation
xamarin-macios copied to clipboard

.NET: Unify the MtouchLink and LinkMode MSBuild properties

Open rolfbjarne opened this issue 4 years ago • 4 comments

We have the MtouchLink property for Xamarin.iOS and the LinkMode property for Xamarin.Mac.

We should unify these for .NET.

Options:

  1. Use LinkMode for both.
  2. Come up with a different name (ideas? Android uses AndroidLinkMode).

I think LinkMode is good enough for us (we're already using it anyway).

rolfbjarne avatar Sep 21 '21 19:09 rolfbjarne

CC @jonathanpeppers: maybe this is something we should coordinate with Android as well?

rolfbjarne avatar Sep 22 '21 12:09 rolfbjarne

We still have $(AndroidLinkMode), but then also newer linker settings:

https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNet.md#linker-illink

SdkOnly for Android is the same as:

<PublishTrimmed>true</PublishTrimmed>
<TrimMode>link</TrimMode>

AndroidLinkMode=Full sets TrimMode="link" on every assembly, and there isn't a new linker setting for this.

It seems like Full isn't highly used, but maybe we should ask someone involved with mono/linker if they would add some property for all platforms for this?

jonathanpeppers avatar Sep 22 '21 12:09 jonathanpeppers

Even though . NET probably came up with the names after xamarin and mono, we should probably use their names? At least maybe use them as the main public options and then use the platform specific ones for finer or advanced control?

mattleibow avatar Jul 01 '22 00:07 mattleibow

They are working on new cross-platform names here:

  • https://github.com/dotnet/linker/pull/2856
  • https://github.com/xamarin/xamarin-android/pull/7132

TrimMode=partial is SdkOnly and TrimMode=link is Full.

I think we should just make it where you could use either the old or new names.

jonathanpeppers avatar Jul 01 '22 13:07 jonathanpeppers

After a talk about this, I believe this is the path forward:

  • Recommend using TrimMode starting in .NET 7 for everybody.
  • Make the old MtouchLink/LinkMode properties keep working as-is (where TrimMode takes precedence if it's set).

rolfbjarne avatar Aug 18 '22 15:08 rolfbjarne