dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 528 forks source link

Changing <Bind> item metadata does not rerun appropriate parts of the build #9184

Open Digifais opened 2 months ago

Digifais commented 2 months ago

Android framework version

net8.0-android

Affected platform version

.NET 8.0.303

Description

When changing item metadata from true to false or vice versa, dotnet build doesn't pick the change up, I need to perform a dotnet clean first before dotnet build works again.

msbuild.binlog.zip

Steps to Reproduce

  1. Create a new Android binding library
  2. Add an AAR to the project and select AndroidLibrary as build action (should add a blank <Bind></Bind>)
  3. Set <Bind> to false.
  4. Build the project through the .NET CLI
  5. Set <Bind> to true
  6. Build the project through the .NET CLI again and see that it produces the same result of not binding the AAR

Did you find any workaround?

Perform dotnet clean first after changing from true to false or vice versa.

Relevant log output

No response

jonathanpeppers commented 2 months ago

We were looking at MSBuild's logic, and putting blank <Bind></Bind> really does clear it. It would invalidate the <ItemDefinitionGroup> here:

https://github.com/dotnet/android/blob/99ba8135fc47358702a5918757651d53d7b6fabd/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.AvailableItems.targets#L48-L51

Digifais commented 2 months ago

@jonathanpeppers So this is really a non-issue and might just be a VS4Mac bug that it adds a blank <Bind></Bind>?

jonathanpeppers commented 2 months ago

@Digifais yes, it looks like it might be that way.

If you see it not taking the change <Bind>true</Bind> vs <Bind>false</Bind> we could look into that.

Digifais commented 2 months ago

@jonathanpeppers As mentioned in the Discord, I indeed need to perform a dotnet clean first when changing the value.

jonathanpeppers commented 2 months ago

I renamed the title, thanks.

Digifais commented 2 months ago

Updated the issue description.