Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@
<AndroidAotProfile Include="$(MSBuildThisFileDirectory)maui-blazor.aotprofile" />
</ItemGroup>

<!--
Enable Composite Partial R2R for Android CoreCLR Release builds by default.
Set MauiEnableFullReadyToRunPublishing to true to use full R2R, which increases
app download size but can improve runtime performance.
Note: PublishReadyToRun and PublishReadyToRunComposite are already set by the Android workload.
_MauiUseDefaultReadyToRunPgoFiles is an internal property that controls inclusion
of the default PGO profiles.
-->
<PropertyGroup Condition="'$(TargetPlatformIdentifier)' == 'android' and '$(UseMonoRuntime)' != 'true' and '$(Configuration)' == 'Release' and '$(PublishReadyToRun)' == 'true'">
<MauiEnableFullReadyToRunPublishing Condition="'$(MauiEnableFullReadyToRunPublishing)' == ''">false</MauiEnableFullReadyToRunPublishing>
<PublishReadyToRunCrossgen2ExtraArgs Condition="'$(MauiEnableFullReadyToRunPublishing)' != 'true'">$(PublishReadyToRunCrossgen2ExtraArgs);--partial</PublishReadyToRunCrossgen2ExtraArgs>
<_MauiUseDefaultReadyToRunPgoFiles Condition="'$(_MauiUseDefaultReadyToRunPgoFiles)' == ''">true</_MauiUseDefaultReadyToRunPgoFiles>
</PropertyGroup>

<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'android' and '$(UseMonoRuntime)' != 'true' and '$(Configuration)' == 'Release' and '$(PublishReadyToRun)' == 'true'">
<!-- Include any default Android PGO profiles under the mibc\android directory. -->
<_ReadyToRunPgoFiles Condition="'$(_MauiUseDefaultReadyToRunPgoFiles)' == 'true'" Include="$(MSBuildThisFileDirectory)mibc\android\**\*.mibc" />
</ItemGroup>

<!-- Check Tasks ABI and other validations -->
<PropertyGroup>
<_MauiTargetsImportedAgain Condition="'$(_MauiTargetsImported)'=='True'">True</_MauiTargetsImportedAgain>
Expand Down
41 changes: 41 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,47 @@ public void BuildAProject()
AssertExists(IOPath.Combine(intermediateDirectory, "XamlC.stamp"));
}

[Theory]
[InlineData(null, false)]
[InlineData("false", false)]
[InlineData("true", true)]
public void MauiEnableFullReadyToRunPublishing_ConfiguresPartialFlagCorrectly(string mauiEnableFullReadyToRunPublishingValue, bool fullReadyToRunPublishingEnabled)
{
SetUp();
var project = NewProject();
var propertyGroup = NewElement("PropertyGroup");
propertyGroup.Add(NewElement("TargetPlatformIdentifier").WithValue("android"));
propertyGroup.Add(NewElement("UseMonoRuntime").WithValue("false"));
propertyGroup.Add(NewElement("Configuration").WithValue("Release"));
propertyGroup.Add(NewElement("PublishReadyToRun").WithValue("true"));
project.Add(propertyGroup);
var target = NewElement("Target").WithAttribute("Name", "TestReadyToRunPublishing");
target.Add(NewElement("Message")
.WithAttribute("Text", "MauiEnableFullReadyToRunPublishing = $(MauiEnableFullReadyToRunPublishing)")
.WithAttribute("Importance", "high"));
target.Add(NewElement("Message")
.WithAttribute("Text", "PublishReadyToRunCrossgen2ExtraArgs = $(PublishReadyToRunCrossgen2ExtraArgs)")
.WithAttribute("Importance", "high"));
project.Add(target);

var projectFile = IOPath.Combine(tempDirectory, "test.csproj");
project.Save(projectFile);
var fullReadyToRunMSBuildArg = mauiEnableFullReadyToRunPublishingValue is null
? string.Empty
: $"-p:MauiEnableFullReadyToRunPublishing={mauiEnableFullReadyToRunPublishingValue}";

var log = Build(
projectFile,
target: "TestReadyToRunPublishing",
additionalArgs: fullReadyToRunMSBuildArg);

Assert.Contains($"MauiEnableFullReadyToRunPublishing = {fullReadyToRunPublishingEnabled.ToString().ToLowerInvariant()}", log, StringComparison.Ordinal);
if (fullReadyToRunPublishingEnabled)
Assert.DoesNotContain("--partial", log, StringComparison.Ordinal);
else
Assert.Contains("PublishReadyToRunCrossgen2ExtraArgs = ;--partial", log, StringComparison.Ordinal);
}

[Theory]
[InlineData("Debug")]
[InlineData("Release")]
Expand Down
Loading