[Xamarin.Android.Build.Tasks] ignore .csproj.user file in $(MSBuildAllProjects) #5283
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 that changing the selected device or emulator in Visual
Studio 2019 16.8 on Windows was causing many MSBuild targets to run
again in the IDE. The time taken was similar to a
Rebuild
!Looking closer, I noticed:
.csproj.user
is where the IDE stores the selected device oremulator. The contents of the file:
The reason this triggers many targets is the file is actually imported:
https://github.com/dotnet/msbuild/blob/7452552ce911efdca6aea5a189c409f083db7bc7/src/Tasks/Microsoft.Common.CurrentVersion.targets#L31
And so this file is automatically included in
$(MSBuildAllProjects)
,which is used by many
Inputs
of Xamarin.Android MSBuild targets.I first tried editing
$(MSBuildAllProjects)
, but this propertyappears to be readonly, since it is a built-in property in MSBuild.
Attempts at setting it were ignored.
To solve this, lets create a new
@(_AndroidMSBuildAllProjects)
itemgroup to be used instead that excludes the
.csproj.user
file.I was able to reproduce this issue in a new test in
IncrementalBuildTest
.After this goes in, there is one place in the xamarin/monodroid repo
that needs to use
@(_AndroidMSBuildAllProjects)
instead of$(MSBuildAllProjects)
.