Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 3881f37

Browse files
[msbuild] make _VerifyXamarinAndroidSupportVersions incremental
When reviewing build logs from 2019 GA, I noticed an MSBuild target from the support libraries taking some time: 377 ms _VerifyXamarinAndroidSupportVersions 1 calls In a build with no changes, it was the 5th longest duration: 463 ms _SetLatestTargetFrameworkVersion 1 calls 554 ms _ResolveAssemblies 1 calls 606 ms _GetProjectReferenceTargetFrameworkProperties 2 calls 682 ms ResolveProjectReferences 2 calls *NOTE: you can do `msbuild foo.csproj /clp:performancesummary` for this breakdown.* It looks like there are a couple things we can improve here: 1. This target runs on design-time builds. 2. This target always runs on every build, even when there is no changes. No. 1 we can add a `Condition`, as I don't think it is worth the build time--DTBs are supposed to be as quick as possible. I don't think it's needed during DTBs at all? For No. 2, we can also skip this target after the first build unless: * The project file changes. * The `AndroidManifest.xml` changes. So I setup a simple `.stamp` file, that will allow these target to skip unless one of the inputs changes. Details about how we do this in Xamarin.Android here: https://github.com/xamarin/xamarin-android/blob/master/Documentation/guides/MSBuildBestPractices.md#stamp-files
1 parent f2e01b6 commit 3881f37

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

source/com.android.support/support-annotations/merge.targets

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
AssemblyFile="Xamarin.Android.Support.BuildTasks.dll"
66
TaskName="Xamarin.Android.Support.BuildTasks.VerifyVersionsTask" />
77

8+
<PropertyGroup>
9+
<_SupportedVersionsStamp>$(IntermediateOutputPath)_VerifyXamarinAndroidSupportVersions.stamp</_SupportedVersionsStamp>
10+
</PropertyGroup>
11+
812
<Target
913
Name="_VerifyXamarinAndroidSupportVersions"
10-
AfterTargets="ResolveAssemblyReferences">
14+
Condition=" '$(DesignTimeBuild)' != 'True' "
15+
AfterTargets="ResolveAssemblyReferences"
16+
Inputs="$(MSBuildProjectFile);$(AndroidManifest)"
17+
Outputs="$(_SupportedVersionsStamp)">
1118

1219
<PropertyGroup>
1320
<XamarinAndroidSupportSkipVerifyVersions Condition="'$(XamarinAndroidSupportSkipVerifyVersions)'==''">false</XamarinAndroidSupportSkipVerifyVersions>
@@ -24,6 +31,14 @@
2431
>
2532
</VerifyVersionsTask>
2633

34+
<Touch
35+
AlwaysCreate="True"
36+
Files="$(_SupportedVersionsStamp)"
37+
/>
38+
<ItemGroup>
39+
<FileWrites Include="$(_SupportedVersionsStamp)" />
40+
</ItemGroup>
41+
2742
</Target>
2843

2944
</Project>

0 commit comments

Comments
 (0)