Files
AI-Studio/app/Trimming.props
T

40 lines
2.6 KiB
XML

<Project>
<!--
How a published build of AI Studio is trimmed. Kept apart from the project of the app, so that every
project which has to trim exactly like the app imports the same settings, instead of a copy which drifts.
-->
<PropertyGroup>
<PublishTrimmed>true</PublishTrimmed> <!-- Publish with trimming, to reduce size -->
<TrimMode>partial</TrimMode> <!-- Trim only assemblies marked as trimmable: all of .NET, but neither our own nor most packages -->
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols> <!-- Remove debug symbols -->
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization> <!-- Remove unsafe binary formatter serialization -->
<EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding> <!-- Remove unsafe UTF7 encoding -->
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault> <!-- Enable reflection for JSON serialization -->
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings> <!-- Suppress trim analysis warnings -->
</PropertyGroup>
<!--
System.Text.Json builds an immutable collection, e.g., the ImmutableHashSet of a chat, through a factory method
like ImmutableHashSet.CreateRange. The contracts which AI Studio generates for its own options call that method
directly, so the trimmer keeps it, and the trim smoke test passes without the line below. A contract which
System.Text.Json builds by reflection, as it still does for the JSON of Blazor, finds the method at runtime
only, and nothing would keep it then. The whole assembly costs about 70 KB more than its trimmed part, so we
keep it, in case such a contract ever meets an immutable collection.
-->
<ItemGroup>
<TrimmerRootAssembly Include="System.Collections.Immutable" />
</ItemGroup>
<!--
Since .NET 10, Blazor carries some state of its own from the page into the circuit as JSON, the antiforgery
token among it. It reads that state by reflection, too, and the trimmer removes the properties of the token,
since nothing else reads them. The circuit then closes right after it started, and the window stays empty.
Microsoft keeps these properties for Blazor WebAssembly only (dotnet/aspnetcore#64819), since it does not
support trimming a Blazor Server app. Hence, we keep the whole assembly which holds the token.
-->
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.AspNetCore.Components.Web" />
</ItemGroup>
</Project>