[macOS] Cannot use PublishTrimmed=true · Issue #19142 · dotnet/macios (original) (raw)

Steps to Reproduce

  1. dotnet new macos
  2. Add <PublishTrimmed>true</PublishTrimmed> to test.csproj
  3. dotnet publish

Expected Behavior

App builds and gets trimmed without errors

Actual Behavior

/usr/local/share/dotnet/sdk/8.0.100-rc.1.23463.5/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(212,5): error NETSDK1191: A runtime identifier for the property 'SelfContained' couldn't be inferred. Specify a rid explicitly. [/Users/me/GitHub/test/test.csproj]

Environment

macos 13.3.8825-net8-rc1/8.0.100-rc.1 SDK 8.0.100-rc.1

Example Project (If Possible)

test.zip

Comments

Until today, I was under the impression, that using TrimMode=full did trim out every unused code from my application. However, I was surprised that my app did not throw any error when using System.Json.Text in .NET8 without source generators. I expected it to throw an System.InvalidOperationException as documented (and I also saw that exception in my .NET8 Android project).
As a side-note / additional question: I also added PublishTrimmed=true to my iOS app, built and uploaded it to TestFlight. It also does not throw the mentioned/expected System.InvalidOperationException. Does the PublishTrimmed property even have any effect in iOS/macOS projects?