[Microsoft.Android.Build.Tasks] Make AssemblyStore zstd compression level configurable#11968
Open
simonrozsival wants to merge 3 commits into
Open
Conversation
…el configurable Add a new `$(_AndroidAssemblyStoreCompressionLevel)` MSBuild property (default 3, matching zstd's current default so behavior is unchanged) that controls the Zstandard compression level used when building the AssemblyStore. Higher levels produce a smaller store at the cost of build time; zstd decompression speed is independent of the level, so raising it has no runtime cost. - `AssemblyCompressor.TryCompress`/`Compress` take a `compressionLevel` argument and pass it to `ZstandardEncoder.TryCompress`. - `CompressAssemblies` gains a `[Required] CompressionLevel` property and validates the range (1-22) up front, reporting `XA5304` when invalid. - `Xamarin.Android.Common.targets` defines the property default, passes it to the task, and includes it in the build-properties cache so changing the level re-triggers the incremental `_CompressAssemblies` target. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new internal MSBuild property ($(_AndroidAssemblyStoreCompressionLevel)) to control the Zstandard compression level used when generating the AssemblyStore, plumbing it through the CompressAssemblies task and ensuring incremental builds re-run when the level changes.
Changes:
- Introduces
$(_AndroidAssemblyStoreCompressionLevel)with a default of3, and wires it into the_CompressAssembliestarget. - Adds
CompressionLevelto theCompressAssembliesMSBuild task and validates the supported level range (1–22), emitting XA5304 on out-of-range values. - Updates assembly compression helpers to pass the chosen level into
ZstandardEncoder.TryCompress.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Defines the new internal property default, includes it in the build-properties cache, and passes it to CompressAssemblies for incremental correctness. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | Adds XA5304 error message text for invalid compression-level values. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs | Regenerates strongly-typed resource accessor for XA5304. |
| src/Microsoft.Android.Build.Tasks/Utilities/AssemblyCompressor.cs | Threads compression level into the underlying zstd encoder call. |
| src/Microsoft.Android.Build.Tasks/Tasks/CompressAssemblies.cs | Adds the new task parameter, validates range, and forwards the level to the compressor. |
Copilot's findings
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
- Files reviewed: 4/5 changed files
- Comments generated: 2
Comment on lines
+43
to
+45
| if (CompressionLevel < MinCompressionLevel || CompressionLevel > MaxCompressionLevel) { | ||
| Log.LogCodedError ("XA5304", Properties.Resources.XA5304, CompressionLevel, MinCompressionLevel, MaxCompressionLevel); | ||
| return false; |
Member
Author
There was a problem hiding this comment.
@copilot add the documentation for this new error code
Contributor
There was a problem hiding this comment.
Done. Added Documentation/docs-mobile/messages/xa5304.md with the error description and solution, and added an entry for XA5304 to Documentation/docs-mobile/messages/index.md (commit $(latest)).
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a new internal MSBuild property,
$(_AndroidAssemblyStoreCompressionLevel), that controls the Zstandard compression level used when building the AssemblyStore.3— zstd's current default — so this change is purely additive and does not alter existing build output.1–22; an out-of-range value fails the build withXA5304.How
AssemblyCompressor.TryCompress/Compresstake acompressionLevelargument and pass it toZstandardEncoder.TryCompress.CompressAssembliesgains a[Required] CompressionLevelproperty and validates the1–22range up front (XA5304).Xamarin.Android.Common.targets:CompressAssembliestask,_CompressAssembliestarget.Notes
Builds on the
Microsoft.Android.Build.Tasks/CompressAssembliesinfrastructure introduced in #11730. This carves the configurable-level knob out of a larger experimental branch so it can land independently.