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] fix cases of missing @(Reference) #7642

Merged
merged 2 commits into from
Jan 4, 2023

Commits on Dec 15, 2022

  1. [Xamarin.Android.Build.Tasks] fix cases of missing @(Reference)

    Fixes: dotnet/maui#10154
    
    If you have a solution setup with:
    
    * `ApplicationA` project reference ->
    * `LibraryB` reference ->
    * `LibraryC`
    
    The app will crash at runtime, due to a missing `LibraryC.dll`.
    
    You can solve the problem by changing `@(Reference)` to a
    `@(ProjectReference)`. However, it appears the same situation works in
    a .NET 7 self-contained console app:
    
        dotnet publish --self-contained -r win-x64
        ...
        ls -n .\bin\Debug\net7.0\win-x64\publish\LibraryC.dll
        LibraryC.dll
    
    The underlying issue appears to be:
    
    https://github.com/dotnet/msbuild/blob/a2490dd3f78cce4abc8f9e6f1b5268437332818f/src/Tasks/Microsoft.Common.CurrentVersion.targets#L2322
    
    In the console app, `$(BuildingProject)` is `true` and
    `$(_FindDependencies)` is empty.
    
    In the android app, `$(BuildingProject)` is `false` and
    `$(_FindDependencies)` is `false`.
    
    It appears the `BuildOnlySettings` target *should* be running in
    Android apps when we do an "inner" build per `$(RuntimeIdentifier)`.
    Simply adding a dependency for the `_ComputeFilesToPublishForRuntimeIdentifiers`
    MSBuild target solves this issue.
    
    This likely might fix other issues, such as:
    
    dotnet/maui#11364
    
    I added a test for this scenario.
    jonathanpeppers committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    c694855 View commit details
    Browse the repository at this point in the history

Commits on Dec 16, 2022

  1. Prevent duplicates in @(_AndroidResolvedSatellitePaths)

    It appears that after we fixed `BuildOnlySettings` in the inner
    builds, that satellite assemblies for assembly references are now
    automatically found by the .NET SDK.
    
    Conditionally add to `@(_AndroidResolvedSatellitePaths)` to avoid
    duplicate satellite assemblies in .NET 6+.
    jonathanpeppers committed Dec 16, 2022
    Configuration menu
    Copy the full SHA
    e9b5957 View commit details
    Browse the repository at this point in the history