Skip to content

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

Merged
rmarinho merged 1 commit into
dotnet:mainfrom
jonathanpeppers:FirstDTB
May 22, 2024
Merged

[android] fix design-time build on project creation#22559
rmarinho merged 1 commit into
dotnet:mainfrom
jonathanpeppers:FirstDTB

Conversation

@jonathanpeppers
Copy link
Copy Markdown
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
@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 fixed-in-8.0.60 fixed-in-9.0.0-preview.5.24307.10

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

5 participants