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

[android] fix design-time build on project creation #22559

Merged
merged 1 commit into from
May 22, 2024

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented May 21, 2024

Fixes: #21777 (comment)

When creating a new .NET MAUI project, the first design-time build can randomly fail with:

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\tools\Xamarin.Android.Common.targets(613,3):
error XA1018: Specified AndroidManifest file does not exist: D:\source\MauiApp3\MauiApp3\AndroidManifest.xml.

This can happen because:

  1. NuGet restore isn't complete

  2. Microsoft.Maui.Controls.SingleProject.targets is not imported

  3. $(AndroidManifest) has not been moved to Platforms/Android/AndroidManifest.xml

This means the Android workload would just look for AndroidManifest.xml in the root of the project, which doesn't exist.

To fix this, let's check for the non-existence of $(AndroidManifest) in the MAUI workload and set it.

After testing this change in:

  • C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\8.0.21\Sdk\Microsoft.Maui.Sdk.After.targets

I don't get a design-time build failure anymore.

/cc @BethMassi

Fixes: dotnet#21777 (comment)

When creating a new .NET MAUI project, the first design-time build
can randomly fail with:

    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\tools\Xamarin.Android.Common.targets(613,3):
    error XA1018: Specified AndroidManifest file does not exist: D:\source\MauiApp3\MauiApp3\AndroidManifest.xml.

This can happen because:

1. NuGet restore isn't complete

2. `Microsoft.Maui.Controls.SingleProject.targets` is not imported

3. `$(AndroidManifest)` has not been moved to `Platforms/Android/AndroidManifest.xml`

This means the Android workload would just look for `AndroidManifest.xml`
in the root of the project, which doesn't exist.

To fix this, let's check for the non-existence of `$(AndroidManifest)` in
the workload and set it.

After testing this change in:

* `C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\8.0.21\Sdk\Microsoft.Maui.Sdk.After.targets`

I don't get a design-time build failure anymore.
@jonathanpeppers jonathanpeppers requested a review from a team as a code owner May 21, 2024 19:29
@Eilon Eilon added the area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging label May 21, 2024
@rmarinho rmarinho merged commit a9ebedb into dotnet:main May 22, 2024
49 checks passed
@jonathanpeppers jonathanpeppers deleted the FirstDTB branch May 23, 2024 00:06
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android Java Library Binding breaks intellisense, despite build/run working
4 participants