forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[One .NET] fix for incremental CoreCompile (dotnet#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.
- Loading branch information
1 parent
11c30ac
commit 905878b
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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