Skip to content

Remove Aspire CLI Native AOT workarounds for NuGet's Newtonsoft.Json dependency #20342

Description

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

#19847 moved bundled NuGet operations into the Native AOT aspire CLI. NuGet.Client 7.12.0-rc.25, which the CLI now consumes, still reaches Newtonsoft.Json on some paths, so src/Aspire.Cli/Aspire.Cli.csproj carries temporary workarounds to keep the Native AOT publish clean:

  • RuntimeHostConfigurationOption items that disable Newtonsoft's Newtonsoft.Json.Linq.JToken.SerializationIsSupported, ComponentModelIsSupported, and DynamicIsSupported feature switches.
  • The ConfigureTrimming target, which collapses the remaining dynamic-dispatch warnings from Microsoft.CSharp and System.Linq.Expressions to one warning per assembly.
  • IL2104;IL3053 in NoWarn, which suppresses those collapsed single-warn diagnostics.

These are only needed until NuGet removes its Newtonsoft.Json dependency from the code paths the CLI uses. Upstream that work is NuGet/NuGet.Client#7601.

The Newtonsoft switches also make the disabled code paths throw NotSupportedException at runtime, so any NuGet update that starts reaching one of them would fail at runtime rather than at publish time.

Describe the solution you'd like

Once NuGet/NuGet.Client#7601 ships in a NuGet.Client release:

  1. Update NuGetPackageVersionForCli in eng/Versions.props to that release.
  2. Remove the three Newtonsoft RuntimeHostConfigurationOption items, the ConfigureTrimming target, and IL2104;IL3053 from NoWarn in src/Aspire.Cli/Aspire.Cli.csproj.
  3. Confirm a fresh Native AOT publish of Aspire.Cli reports no IL trim/AOT diagnostics without them. ILC is incremental, so delete artifacts/obj/Aspire.Cli/<config>/<tfm>/<rid>/native first or a repeat publish can report zero diagnostics without recompiling.

NuGet.UseSystemTextJsonDeserialization may still be required after that change; keep or remove it based on NuGet's AOT guidance at the time.

Additional context

Tracked for 14.0 so the workarounds are not left in place after the upstream fix ships.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions