dotnet / dotnet/android

Pre-build event should run before checking for AndroidManifest.xml (XA1018)

Open
#9,021 5 comments 0 reactions 2 assignees Assigned to @dellis1972 View on GitHub
Area: App+Library Build
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 20h
Merged PRs (30d)
257

Description

### Android framework version

Other

### Affected platform version

VS 2022 / net7.0-android

### Description

In my Xamarin app, I have a pre-build event that runs a script which generates AssemblyInfo.cs (Windows), Info.plist (iOS) and AndroidManifest.xml (Android) from a template, filling in some version info (i.e. git commit hash, etc). The repo includes the template file, i.e. AndroidManifest.template.xml; AndroidManifest.xml itself is .gitignored, since its contents change with each build.

On Windows & iOS, this works great. However on Android, it seems to check for the existence of AndroidManifest.xml *before* running the pre-build event, saying:

```
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\tools\Xamarin.Android.Common.targets(574,3): error XA1018: Specified AndroidManifest file does not exist: D:\Work\USRadar\_Solution_\RadarMP\RadarMP.Android\AndroidManifest.xml.
```

Since it checks for this *before* pre-build, the script can't run & generate AndroidManifest.xml from the template. I therefore have to manually create a "dummy" AndroidManifest.xml every time I checkout the repo, just so the first-time build will run the pre-build event & generate the real AndroidManifest.xml. All builds after that work.

How can I get the Android project to run the pre-build event, before checking for that file, similar to Windows & iOS?

### Steps to Reproduce

Please see description

### Did you find any workaround?

_No response_

### Relevant log output

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.