Commit 905878b
authored
[One .NET] fix for incremental CoreCompile (#5661)
Context: https://github.com/xamarin/Xamarin.Forms/tree/main-handler
I noticed that when building Maui, `CoreCompile` seems to be running
on every build no matter what:
Building target "CoreCompile" completely.
Input file "obj\Debug\net6.0-android\Core-net6.csproj.CoreCompileInputs.cache" is newer than output file "bin\Debug\net6.0-android\Microsoft.Maui.xml".
I could reproduce this in a test:
* Build `AppA` & `LibraryB`
* Build `AppA` & `LibraryB` again, `LibraryB` will run `CoreCompile`
*every* time.
There is a `_GenerateCompileDependencyCache` target that basically does:
<Hash ItemsToHash="@(CoreCompileCache)">
<Output TaskParameter="HashResult" PropertyName="CoreCompileDependencyHash" />
</Hash>
<WriteLinesToFile
Lines="$(CoreCompileDependencyHash)"
File="$(IntermediateOutputPath)$(MSBuildProjectFile).CoreCompileInputs.cache"
Overwrite="True"
WriteOnlyWhenDifferent="True"
/>
https://github.com/dotnet/msbuild/blob/83cd7d4e36b71d5b2cefd02cb9a5a58d27dd6a75/src/Tasks/Microsoft.Common.CurrentVersion.targets#L3529
This `*.CoreCompileInputs.cache` file triggers `CoreCompile` to run
again when it needs to.
However, this file is actually updating on every build, because:
1. Our "outer" build has all our preprocessor defines listed in
`@(CoreCompileCache)` like `__MOBILE__`, `__ANDROID__`, etc.
2. The "inner" build for each `$(RuntimeIdentifier)` does *not* have
these symbols!
And so we get into a situation where `CoreCompile` will always run.
The inner & outer builds write different values in this file.
To solve this problem, I added our `_AddAndroidDefines` to run before
`CoreCompile` in inner builds.
I also needed some changes to our MSBuild test framework:
* Make `IsTargetSkipped()` and `AssertTargetIsSkipped()` supported for
new project types.
* Make `IsTargetSkipped()` return `false` if a `Building target
"{target}" completely.` message is found.1 parent 11c30ac commit 905878b
File tree
5 files changed
+65
-2
lines changed- src/Xamarin.Android.Build.Tasks
- Microsoft.Android.Sdk/targets
- Tests
- Xamarin.Android.Build.Tests
- Utilities
- Xamarin.ProjectTools/Common
5 files changed
+65
-2
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/AssertionExtensions.cs
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
30 | 48 | | |
31 | 49 | | |
32 | 50 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
553 | 588 | | |
554 | 589 | | |
555 | 590 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
0 commit comments