Skip to content
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

[Xamarin.Android.Build.Tasks] Move DesignTime Designer to $(BaseIntermediateOutputPath) #1294

Closed
wants to merge 2 commits into from

Conversation

dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Feb 12, 2018

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 keeps
removing the files. But in addition to this the Clean target
also ends up deleting these files. However our existing fix does
not work since IncrementalClean is not called. So the code we
have 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 in
MSBuild.

Those does present a problem with our xbuild support. xbuild has
a target CoreClean which is called when Clean is called. However
it also calls _GetCleanFileWrites which populates the PreviousFileWrites
ItemGroup with files in the $(CleanFile). As a result xbuild deletes
the files even if they are in $(BaseIntermediateOutputPath). This
behaviour is different from MSBuild.

Interestingly Xamarin.Android.Windows.targets has some code in it already
to 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 to
handle 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 time
files 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.

@dellis1972
Copy link
Contributor Author

@pjcollins I'll be dealing with the Clean issue here :)

…rmediateOutputPath)`.

Fixes dotnet#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` keeps
removing the files. But in addition to this the `Clean` target
also ends up deleting these files. However our existing `fix` does
not work since `IncrementalClean` is not called. So the code we
have 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 in
MSBuild.

Those does present a problem with our `xbuild` support. xbuild has
a target `CoreClean` which is called when `Clean` is called. However
it also calls `_GetCleanFileWrites` which populates the `PreviousFileWrites`
ItemGroup with files in the `$(CleanFile)`. As a result xbuild deletes
the files even if they are in `$(BaseIntermediateOutputPath)`. This
behaviour is different from MSBuild.

Interestingly `Xamarin.Android.Windows.targets` has some code in it already
to 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 to
handle 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 time
files 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.
@dellis1972 dellis1972 changed the title Issue1286 [WIP] [Xamarin.Android.Build.Tasks] Move DesignTime Designer to $(BaseIntermediateOutputPath) Feb 13, 2018
@dellis1972 dellis1972 removed the do-not-merge PR should not be merged. label Feb 13, 2018
@dellis1972 dellis1972 closed this Feb 13, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 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.

Resource related intellisense breaks after Rebuilding
1 participant