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

[One .NET] prefer /manifest/@android:versionCode #6383

Merged
merged 2 commits into from Oct 12, 2021

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Oct 11, 2021

Fixes: #6384
Fixes: dotnet/sdk#21614

In .NET 6, you can't currently put versionCode in
AndroidManifest.xml, as it is always overwritten by a default:

<ApplicationVersion Condition=" '$(ApplicationVersion)' == '' ">1</ApplicationVersion>

We should actually check if the value is present in
AndroidManifest.xml and only set if blank.

The other new MSBuild properties don't appear to suffer from this
problem:

  • $(ApplicationId)
  • $(ApplicationTitle)
  • $(ApplicationDisplayVersion)

This is because we don't default these properties to a value when they
are blank.

I added a new test for this scenario.

Fixes: dotnet/sdk#21614

In .NET 6, you can't currently put `versionCode` in
`AndroidManifest.xml`, as it is always overwritten by a default:

    <ApplicationVersion Condition=" '$(ApplicationVersion)' == '' ">1</ApplicationVersion>

We should actually check if the value is present in
`AndroidManifest.xml` and only set if blank.

The other new MSBuild properties don't appear to suffer from this
problem:

* `$(ApplicationId)`
* `$(ApplicationTitle)`
* `$(ApplicationDisplayVersion)`

This is because we don't default these properties to a value when they
are blank.

I added a new test for this scenario.
@jpobst
Copy link
Contributor

jpobst commented Oct 11, 2021

It kinda feels like if you put a version in both <ApplicationVersion> and AndroidManifest.xml, the <ApplicationVersion> version should win, as it is much more flexible, especially for CI scenarios.

Is there a way to set the precedence to:

  • User set <ApplicationVersion>
  • AndroidManifest.xml
  • Default <ApplicationVersion>

@jonathanpeppers
Copy link
Member Author

The spec says the native platform files always win:

https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetSingleProject.md

If you want to use the MSBuild properties, you can just leave the values blank in Info.plist or AndroidManifest.xml (or whatever the WinUI version is). You can still set MSBuild properties in .csproj files and override their values from CI.

I updated the test case some -- it needs to set all the properties to weird values so we see who wins.

@jonpryor jonpryor merged commit 556b043 into xamarin:main Oct 12, 2021
@jonathanpeppers jonathanpeppers deleted the dotnet-androidmanifest-wins branch October 12, 2021 15:10
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants