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] ignore .csproj.user file in $(MSBuildAllProjects) #5283

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

jonathanpeppers
Copy link
Member

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:

Building target "_CompileJava" completely.
Input file "App42.csproj.user" is newer than output file "obj\Debug\_javac.stamp".

.csproj.user is where the IDE stores the selected device or
emulator. The contents of the file:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <SelectedDevice>pixel_2_pie_9_0_-_api_28</SelectedDevice>
    <DefaultDevice>pixel_2_pie_9_0_-_api_28</DefaultDevice>
  </PropertyGroup>
</Project>

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 property
appears 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) item
group 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).

@jonathanpeppers
Copy link
Member Author

I manually tested a build from here, and everything seems to work switching from x86 emulator to x86_64 to arm64-v8a device.

I also edited the .csproj to make sure the targets that should run, still do.

…lProjects)

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:

    Building target "_CompileJava" completely.
    Input file "App42.csproj.user" is newer than output file "obj\Debug\_javac.stamp".

`.csproj.user` is where the IDE stores the selected device or
emulator. The contents of the file:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <SelectedDevice>pixel_2_pie_9_0_-_api_28</SelectedDevice>
        <DefaultDevice>pixel_2_pie_9_0_-_api_28</DefaultDevice>
      </PropertyGroup>
    </Project>

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 property
appears 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)` item
group 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)`.
@jonpryor jonpryor merged commit fd8aa17 into dotnet:master Dec 2, 2020
@jonathanpeppers jonathanpeppers deleted the incremental-csproj.user branch December 2, 2020 21:16
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 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