[Xamarin.Android.Build.Tasks] Move DesignTime Designer to $(BaseIntermediateOutputPath)
#1294
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.
Fixes #1286
One of the problems we face with design time builds is MSBuild
keeps deleting our files. As a result the design time build keeps
failing. The main reason for this is
IncrementalClean
keepsremoving the files. But in addition to this the
Clean
targetalso ends up deleting these files. However our existing
fix
doesnot work since
IncrementalClean
is not called. So the code wehave to save the files is not called.
One solution is to move the generated files out from the
$(IntermediateOutputPath)
and into the$(BaseIntermediateOutputPath)
.The latter is not cleaned by the
IncrementalClean
target inMSBuild.
Those does present a problem with our
xbuild
support. xbuild hasa target
CoreClean
which is called whenClean
is called. Howeverit also calls
_GetCleanFileWrites
which populates thePreviousFileWrites
ItemGroup with files in the
$(CleanFile)
. As a result xbuild deletesthe files even if they are in
$(BaseIntermediateOutputPath)
. Thisbehaviour is different from MSBuild.
Interestingly
Xamarin.Android.Windows.targets
has some code in it alreadyto determine if we are running under MSBuild or xbuild. It also contains
the code for dealing with the
IncrementalClean
target problems.Since we need some of those code on any platform that uses MSBuild
(Windows, Mac and Linux) we should move some of that code into the
main
Xamarin.Android.Common.targets/props
and reuse some of it tohandle this problem.
The code to check if we are running on MSBuild or xbuild is now in
Xamarin.Android.Common.props
. The_RegisterAndroidFilesWithFileWrites
is now in
Xamarin.Android.Common.targets
along side a new target_OverrideXbuildCleanFileWrites
which will prevent the design timefiles from being deleted under xbuild.
The various tests have been updated to reflect this new setup. A new
test to make sure we never delete these files has been added.