Add MIBC profile generator for InitializeComponent methods#34837
Open
jkoritzinsky wants to merge 6 commits intomainfrom
Open
Add MIBC profile generator for InitializeComponent methods#34837jkoritzinsky wants to merge 6 commits intomainfrom
jkoritzinsky wants to merge 6 commits intomainfrom
Conversation
Add a build tool that scans compiled MAUI assemblies for all InitializeComponent* methods (InitializeComponent, InitializeComponentRuntime, InitializeComponentXamlC, InitializeComponentSourceGen) and produces a MIBC profile file consumable by crossgen2 and the .NET AOT compiler for PGO. The tool is integrated into the MSBuild pipeline via the _MauiGenerateMibcProfile target, which runs after XamlC and is opt-in via the MauiGenerateMibcProfile property. The generated file is exposed as the @(MauiMibcProfile) MSBuild item for downstream consumption. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add explicit ret instructions to group and AssemblyDictionary IL methods - Fix nested type namespace resolution (walk to outermost declaring type) - Include deps.json in NuGet package and local dev copy - Fix comment to match actual property/item names - Fix indentation to use tabs consistently in targets file Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…cios repo and use item groups from dotnet/sdk#53635 to enable partial generation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34837Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34837" |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an MSBuild-integrated tool to generate MIBC profile files containing MAUI InitializeComponent* methods, enabling partial ReadyToRun (R2R) compilation for XAML-generated code paths (notably for CoreCLR Debug scenarios).
Changes:
- Introduces
MibcProfileGenerator, a console tool that scans assemblies viaSystem.Reflection.Metadataand emits a MIBC PE (optionally compressed). - Adds an opt-in MSBuild target (
_MauiGenerateMibcProfile) to generate the profile and wire it intoPublishReadyToRun*items. - Packages the tool alongside existing build tasks and hooks it into the build tasks project/pack output.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets | Adds _MauiGenerateMibcProfile target and R2R/PGO item wiring. |
| src/Controls/src/Build.Tasks/MibcProfileGenerator/Program.cs | New implementation for discovering InitializeComponent* methods and emitting MIBC output. |
| src/Controls/src/Build.Tasks/MibcProfileGenerator/MibcProfileGenerator.csproj | New net10.0 tool project and local dev copy target. |
| src/Controls/src/Build.Tasks/Controls.Build.Tasks.csproj | References/packaging updates to include the tool in the build tasks NuGet output. |
- Fix MVID write ordering: write GUID before Serialize() so it's included in output - Key assembly references by full identity (name+version+pkt) not just simple name - Add MauiXaml condition to skip non-XAML projects - Fix comment: 'method names' not 'method name prefixes' (exact matching) - Fix comment: describe actual enabling mechanism (FilterReadyToRunAssemblies) - Fix indentation in targets file ItemGroup (tabs not spaces) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add response file (@file) support to MibcProfileGenerator tool - Restructure targets into wrapper + write-rsp + run-tool pattern - Use WriteOnlyWhenDifferent for incremental build correctness - Pass all PublishReadyToRunExclude assemblies to the generator - Move all excluded assemblies to partial R2R after generation Co-authored-by: Copilot <223556219+Copilot@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.
Summary
Adds a build tool that generates MIBC (Managed Instrumented Binary Code) profile files listing all
InitializeComponent*methods from compiled MAUI assemblies. These files do not have any actual profile data, but they can be consumed by crossgen2 for partial compilation. Also add MSBuild targets to enable partial R2R for just XAML-generated code when the .NET for iOS SDK is enabling their partial R2R support.What's included
MibcProfileGenerator tool (src/Controls/src/Build.Tasks/MibcProfileGenerator/)
A standalone .NET console app that:
InitializeComponent— primary entry pointInitializeComponentRuntime— runtime XAML inflationInitializeComponentXamlC— XamlC IL-compiled pathInitializeComponentSourceGen— source generator compiled path.mibc) and uncompressed (.dll) outputdotnet-pgo dumpMSBuild integration
_MauiGenerateMibcProfileinMicrosoft.Maui.Controls.targets_SelectUserAssembliesso it can see all user assemblies that may have XAML in the application.Packaging
_CopyToBuildTasksDirtargetUsage
Enabled in .NET for iOS Debug builds when targeting CoreCLR.
Supersedes #34660 so CI can run