Skip to content

NET8 Android binding library generated sources are deleted when app resources are updated #8658

Closed
@uholeschak

Description

@uholeschak

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

VS2022 17.8.5

Description

The NET8 Android binding library generates it sources files at obj\$(Configuration)\$(TargetFramework)\generated\src.
When the resources of the corresponding app are updated by MSBuild:UpdateGeneratedFiles the msbuild target PrepareResources is called, which deletes the generated sources.
When debugging this causes problems, because the source has changed.
Building the application fails if resources files are open.

Steps to Reproduce

  1. Create NET8 Android binding library for an .AAR file
  2. Use the binding library in a application as project reference
  3. Build the application
  4. Check the binding library generated source at obj\$(Configuration)\$(TargetFramework)\generated\src
  5. Open the app Android resource and change it
  6. Watch obj\$(Configuration)\$(TargetFramework)\generated\src, the source will be deleted after some delay.
  7. While debugging (hitting a break point) the hot reload window is displayed, because the source files have been deleted.

Did you find any workaround?

Create a file Directory.Build.targets in the Android binding library project directory

<Project>
    <Target Name="PrepareResources" DependsOnTargets="$(PrepareResourcesDependsOn)" Condition="'$(DesignTimeBuild)'!='true'">
        <Message Text="PrepareResources modified" Importance="High" />
    </Target>
</Project>

Add to all projects in the solution:

    <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>

This disables the resource update in the Android binding library

Relevant log output

No response

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions