[build] fix broken incrementality of Mono.Android.csproj#10578
Merged
[build] fix broken incrementality of Mono.Android.csproj#10578
Mono.Android.csproj#10578Conversation
I noticed this was happening like for *every* build...
> .\dotnet-local.cmd build .\src\Mono.Android\Mono.Android.csproj -bl
...
Build succeeded with 78 warning(s) in 125.6s
Even with no changes!
I tracked this down to this chain of events:
Mono.Android.csproj
Target CoreCompile
Building target "CoreCompile" completely.
Input file "Android.Runtime\JNIEnv.g.cs" is newer than output file "obj\Debug\net10.0\android-36\Mono.Android.pdb".
...
Target _BuildJNIEnv
Building target "_BuildJNIEnv" completely.
Input file "..\..\bin\BuildDebug\jnienv-gen.dll" is newer than output file "../../src/Mono.Android/Android.Runtime/JNIEnv.g.cs".
...
Target CoreCompile
Building target "CoreCompile" completely.
Input file "D:\src\xamarin-android\bin\Debug\lib\packs\Microsoft.Android.Sdk.Windows\36.1.99\Sdk\AutoImport.props" is newer than output file "obj\Debug\net9.0\jnienv-gen.pdb".
Reviewing the `_GenerateBundledVersions` MSBuild target, it just runs
every time! No `Inputs` or `Outputs` are defined, so it is always
considered out-of-date.
I created a new `_WriteBundledVersionsCache` target that writes a
cache file with all important properties, and then made
`_GenerateBundledVersions` depend on that target, and added `Inputs`
and `Outputs` to it.
This appears to speed up our builds significantly!
> .\dotnet-local.cmd build .\src\Mono.Android\Mono.Android.csproj -bl
...
Build succeeded in 2.1s
grendello
approved these changes
Nov 7, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
I noticed this was happening like for every build...
Even with no changes!
I tracked this down to this chain of events:
Reviewing the
_GenerateBundledVersionsMSBuild target, it just runs every time! NoInputsorOutputsare defined, so it is always considered out-of-date.I created a new
_WriteBundledVersionsCachetarget that writes a cache file with all important properties, and then made_GenerateBundledVersionsdepend on that target, and addedInputsandOutputsto it.This appears to speed up our builds significantly!