Skip to content

[Xamarin.Android.Build.Tasks] Dont use a temp location for AssemblyAttribute.cs #3354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2019

Conversation

dellis1972
Copy link
Contributor

Context #1240

As part of the build process MSBuild generates an
AssemblyAttribute.cs class, such as

MonoAndroid,Version=v9.0.AssemblyAttributes.cs

This is the file which adds the TargetFrameworkAttribute
to the assembly. While investigating #1240 I noticed that
_GenerateJavaStubs was ALWAYS running, even on
incremental builds with no changes. Digging into the build
logs, CoreCompile was running because it thought one
of 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.

Input file "/var/folders/n_/vt_nzq1n04schx5yy2jgcgcw0000gn/T/MonoAndroid,Version=v9.0.AssemblyAttributes.cs" is newer than output file "obj/Release/Xamarin.Android.McwGen-Tests.pdb".

It turns out our binding targets were missing a few lines which
exist in the common targets. These line set the
TargetFrameworkMonikerAssemblyAttributesPath msbuild property
to be located in the $(IntermediateOutputPath). If this
value 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 were
no 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.

…tribute.cs

Context dotnet#1240

As part of the build process MSBuild generates an
`AssemblyAttribute.cs` class, such as

	MonoAndroid,Version=v9.0.AssemblyAttributes.cs

This is the file which adds the `TargetFrameworkAttribute`
to the assembly. While investigating dotnet#1240 I noticed that
`_GenerateJavaStubs` was ALWAYS running, even on
incremental builds with no changes. Digging into the build
logs, `CoreCompile` was running because it thought one
of 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.

	Input file "/var/folders/n_/vt_nzq1n04schx5yy2jgcgcw0000gn/T/MonoAndroid,Version=v9.0.AssemblyAttributes.cs" is newer than output file "obj/Release/Xamarin.Android.McwGen-Tests.pdb".

It turns out our binding targets were missing a few lines which
exist in the common targets. These line set the
`TargetFrameworkMonikerAssemblyAttributesPath` msbuild property
to be located in the `$(IntermediateOutputPath)`. If this
value 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 were
no 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.
@dellis1972 dellis1972 merged commit c26a8f0 into dotnet:master Jul 18, 2019
@dellis1972 dellis1972 deleted the bindingtargets branch July 18, 2019 14:10
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants