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 versionCode gets set to 1 regardless of value in manifest #6384
Comments
Issue moved from dotnet/sdk#21614
From @dotnet-issue-labeler[bot] on Thursday, September 30, 2021 9:28:45 PM I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Issue moved from dotnet/sdk#21614
From @mungojam on Saturday, October 2, 2021 2:01:58 PM The failure appears to be around not picking up the version from the manifest, rather than a failure to write out the version. The following addition correctly outputs a version of 888 in the obj manifest. This is also a workaround for now <AndroidVersionCodePattern>{myVersion}</AndroidVersionCodePattern>
<AndroidVersionCodeProperties>myVersion=888</AndroidVersionCodeProperties> |
Issue moved from dotnet/sdk#21614
From @sfoslund on Wednesday, October 6, 2021 5:26:49 PM @jonathanpeppers where should I transfer android specific issues? |
Issue moved from dotnet/sdk#21614
From @jonathanpeppers on Monday, October 11, 2021 1:59:52 PM @sfoslund I don't know if we can transfer across Github organizations: https://github.com/xamarin/xamarin-android/issues @mungojam our templates put the version like this in RC 2: <ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> So the same MSBuild properties can work on iOS, tvOS, etc. Docs on this here. You could leave the Your case still seems like it might be a bug, I'll test this. |
Issue moved from dotnet/sdk#21614
From @sfoslund on Monday, October 11, 2021 4:46:32 PM We use this tool to transfer when Github can't do it: https://hubbup.io/Mover |
I love that move towards using just msbuild props for these. Thanks for the docs pointer, presumably it will end up on the .net docs in good time. Thanks for the fix, I'll try the new way in my own project. |
Fixes: dotnet/sdk#21614 Fixes: #6384 Context: 84d0d9b Context: https://github.com/xamarin/xamarin-android/blob/650f289301583003aa4acb075923bcc5627b92dc/Documentation/guides/OneDotNetSingleProject.md In .NET 6, if [`/manifest/@android:versionCode`][0] is within [`AndroidManifest.xml`][1], it won't be used, as it is always overwritten by a default value: <ApplicationVersion Condition=" '$(ApplicationVersion)' == '' ">1</ApplicationVersion> The other new MSBuild properties don't appear to suffer from this problem; values within `Properties\AndroidManifest.xml` always take precedence over MSBuild properties, [as documented in the spec][2]: * `$(ApplicationDisplayVersion)` * `$(ApplicationId)` * `$(ApplicationTitle)` This is because we don't default these properties to a value when they are blank. Fix this scenario by updating the `<GenerateJavaStubs/>` task to only set `ManifestDocument.VersionCode` when `ManifestDocument.HasVersionCode` is false and the version code is set. I added a new test for this scenario. [0]: https://developer.android.com/guide/topics/manifest/manifest-element#vcode [1]: https://developer.android.com/guide/topics/manifest/manifest-intro [2]: https://github.com/xamarin/xamarin-android/blob/650f289301583003aa4acb075923bcc5627b92dc/Documentation/guides/OneDotNetSingleProject.md
Issue moved from dotnet/sdk#21614
From @mungojam on Thursday, September 30, 2021 9:28:42 PM
Describe the bug
In .net 6 RC1 SDK, the versionCode in Android that is output to
obj
and to the eventual package gets reset to 1, regardless of what I have set in theAndroidManifest.xml
.I've tried various alternatives to the MSBuild properties, e.g. enabling legacy treatment
AndroidUseLegacyVersionCode
, changing the pattern withAndroidVersionCodePattern
or leaving them all out as per thedotnet new android
template. My repro below is for out-of-the-box behaviour. Nothing I found would set the version correctly, it always got set to 1.To Reproduce
dotnet build -c Release
dotnet publish -c Release
bin\Release\net6.0-android\publish
, and find the manifest which shows a version of 1 rather than 99obj\Release\net6.0-android\android\AndroidManifest.xml
fileThe above repo was created using:
dotnet new android
with dotnet 6 RC1 sdkversionCode
from 1 to 99 in the AndroidManifest.xml at the root of the repo.Further technical details
No IDEs directly involved. I did it all from command line
The text was updated successfully, but these errors were encountered: