Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[One .NET] rework $(ApplicationVersion) and $(ApplicationDisplayVersi…
…on) (#6139) Context: dotnet/maui#1662 In commit 4f74bab we were mapping MSBuild properties to values in `AndroidManifest.xml`: * `$(AndroidVersionCode)` -> `android:versionCode` * `$(ApplicationVersion)` -> `android:versionName` To be more consistent with other platforms, we're reworking this to be: * `$(ApplicationVersion)` -> `android:versionCode` * `$(ApplicationDisplayVersion)` -> `android:versionName` If we force `$(ApplicationVersion)` to be an integer, you can use the same values on all platforms dotnet/maui supports. We no longer need an Android-specific `$(AndroidVersionCode)`. We also need to consider the `$(Version)` property that influences `$(AssemblyVersion)`, `$(FileVersion)`, and `$(InformationalVersion)`. We can simply set `$(Version)` when `$(ApplicationDisplayVersion)` is set to influence *all* the version values. Unfortunately, if `$(Version)` is not parsable by [`Version.Parse()`][0], [NuGet will error out][1]. We can use @jonpryor's clever hack to detect when `$(ApplicationDisplayVersion)` is not a valid `System.Version`, setting `$(Version)` only when `$(ApplicationDisplayVersion)` is valid: <Version Condition=" $([System.Version]::TryParse ( '$(ApplicationDisplayVersion)', $([System.Version]::Parse('1.0')))) " >$(ApplicationDisplayVersion)</Version> I updated tests and documentation around this scenario. I also updated the `dotnet new android` project template. There will need to be future changes in xamarin/xamarin-macios for Apple platforms and dotnet/maui for WinUI. [0]: https://docs.microsoft.com/en-us/dotnet/api/system.version.parse?view=net-5.0 [1]: NuGet/Home#11230
- Loading branch information
1 parent
58c8d5e
commit da5b904
Showing
6 changed files
with
115 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:versionCode="1" | ||
android:versionName="1.0" | ||
package="com.companyname.AndroidApp1"> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters