[Xamarin.Android.Build.Tasks] Dont use a temp location for AssemblyAttribute.cs #3354
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.
Context #1240
As part of the build process MSBuild generates an
AssemblyAttribute.cs
class, such asThis is the file which adds the
TargetFrameworkAttribute
to the assembly. While investigating #1240 I noticed that
_GenerateJavaStubs
was ALWAYS running, even onincremental builds with no changes. Digging into the build
logs,
CoreCompile
was running because it thought oneof the binding project assemblies was newer..?
Digging in a bit more and I found this in the Binding Library
build output on the
CoreCompile
target.It turns out our binding targets were missing a few lines which
exist in the common targets. These line set the
TargetFrameworkMonikerAssemblyAttributesPath
msbuild propertyto be located in the
$(IntermediateOutputPath)
. If thisvalue is NOT set it turns out MSBuild defaults to dropping
this file into a temp directory. That means it can be cleaned
up at any point which will trigger a full build. :face_palm.
So lets use the same few lines from the common targets to
make sure we generate this file in our
$(IntermediateOutputPath)
.This stopped
_GenerateJavaStubs
from running when there wereno changes (as expected).
I updated one of our binding tests to check to make sure certain
targets DO NOT run on an incremental build. Similar to what we
do with our application targets.