-
Notifications
You must be signed in to change notification settings - Fork 529
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
[msbuild] support AndroidManifest.xml placeholders. #342
Conversation
@@ -38,6 +38,7 @@ public class GenerateJavaStubs : Task | |||
public bool Debug { get; set; } | |||
public string ApplicationName { get; set; } | |||
public string PackageName { get; set; } | |||
public string ManifestPlaceholders { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a string[]
, not a string
. See also the ReplaceFileContents.Replacements
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that's true. Updating.
@@ -790,6 +791,13 @@ public void Save (System.IO.TextWriter stream) | |||
var s = new StreamReader (ms).ReadToEnd (); | |||
if (ApplicationName != null) | |||
s = s.Replace ("${applicationId}", ApplicationName); | |||
if (Placeholders != null) | |||
foreach (var entry in Placeholders.Split (';').Select (e => e.Split ('='))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting on ;
shouldn't be needed after moving to string[]
. Additionally, the e.Split('=')
should instead use the string.Split(char[], int, StringSplitOptions)
overload:
static readonly char[] Separator = new [] { '=' };
...
... e.Split (Separator, 2, StringSplitOptions.RemoveEmptyEntries)
e1be4ac
to
3d41c0b
Compare
@@ -790,6 +791,13 @@ public void Save (System.IO.TextWriter stream) | |||
var s = new StreamReader (ms).ReadToEnd (); | |||
if (ApplicationName != null) | |||
s = s.Replace ("${applicationId}", ApplicationName); | |||
if (Placeholders != null) | |||
foreach (var entry in Placeholders.Select (e => e.Split ('='))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use string.Split(char[], int, StringSplitOptions)
:
foreach (var entry in Placeholders.Select (e => e.Split (new[]{'='}, 2, StringSplitOptions.None)) {
if (entry.Length < 2) {
log.LogWarning ($"Invalid application placeholders $(AndroidApplicationPlaceholders) value. Use `key1=value1;key2=value2` format. The specified value was: {string.Join (';', Placeholders})");
continue;
}
s = s.Replace ("${" + entry [0] + "}", entry [1]);
}
This overload removes the need to `string.Join ("=", entry.Skip(1)).
We should probably have a test for this as well, perhaps by using |
3d41c0b
to
77fb54a
Compare
A corresponding test is being added to our msbuild tests (which should become public too). |
This needs updates from @jonpryor. |
We only support ${applicationId} so far, but it seems to be used a lot as https://developer.android.com/studio/build/manifest-build-variables.html Since we are not using Gradle, we'd need something similar to it, which is therefore MSBuild property.
77fb54a
to
8bacb4b
Compare
Is this PR released in any Xamarin android version? |
@jzeferino: It's in Xamarin.Android 7.2, currently in the Beta channel. |
Xamarin.Android v11.3.0 will be shipped as part of Visual Studio 2019 16.10 Preview 3 and subsequent releases. Changes: mono/debugger-libs@8bf09ce...08268b7 * mono/debugger-libs@08268b7: Add Module.ApplyChanges (#342) * mono/debugger-libs@1b5a55a: Fix assembly version after converting projects to SDK style Changes: dotnet/java-interop@f9faaab...f39db25 * dotnet/java-interop@f39db25c: Branching for d16-10. * dotnet/java-interop@f4e68b5b: [generator] Separate metadata fixup step from parsing step. (#822) Changes: xamarin/monodroid@76c04cd...69e9111 * xamarin/monodroid@69e911139: Branching for d16-10. * xamarin/monodroid@9f9ee378c: [tools/msbuild] Missing translations for XA0135 (#1198) Changes: dotnet/android-tools@d92fc3e...c5732a0 * dotnet/android-tools@c5732a0: [Xamarin.Android.Tools.AndroidSdk] Support Microsoft Dist JDK (#117) * dotnet/android-tools@52ef989: [Xamarin.Android.Tools.AndroidSdk] Fix CS0168 warning (#116)
Xamarin.Android v11.3.0 will be shipped as part of Visual Studio 2019 16.10 Preview 3 and subsequent releases. Changes: mono/debugger-libs@8bf09ce...08268b7 * mono/debugger-libs@08268b7: Add Module.ApplyChanges (#342) * mono/debugger-libs@1b5a55a: Fix assembly version after converting projects to SDK style Changes: dotnet/java-interop@f9faaab...f39db25 * dotnet/java-interop@f39db25c: Branching for d16-10. * dotnet/java-interop@f4e68b5b: [generator] Separate metadata fixup step from parsing step. (#822) Changes: xamarin/monodroid@76c04cd...69e9111 * xamarin/monodroid@69e911139: Branching for d16-10. * xamarin/monodroid@9f9ee378c: [tools/msbuild] Missing translations for XA0135 (#1198) Changes: dotnet/android-tools@d92fc3e...c5732a0 * dotnet/android-tools@c5732a0: [Xamarin.Android.Tools.AndroidSdk] Support Microsoft Dist JDK (#117) * dotnet/android-tools@52ef989: [Xamarin.Android.Tools.AndroidSdk] Fix CS0168 warning (#116)
(Commercial) Xamarin.Android v11.3 is being tracked in the [xamarin-android/d16-10][0] branch, which was branched from commit eac74eb. Bump `$(ProductVersion)` to 11.3.99 to track development progress of the *next* version of Xamarin.Android. Additionally, bump various submodules to their "main" equivalents to mirror the d16-10 branch commit 496a43a, and update `.gitmodules` so that the correct branch name is used: Changes: mono/debugger-libs@8bf09ce...08268b7 * mono/debugger-libs@08268b7: Add Module.ApplyChanges (dotnet#342) * mono/debugger-libs@1b5a55a: Fix assembly version after converting projects to SDK style Changes: mono/opentk@933939d...50128f7 * mono/opentk@50128f7a: Create Xamarin.Legacy.OpenTK Nuget Package (dotnet#28) * mono/opentk@72f4b085: Merge pull request dotnet#26 from dellis1972/ci * mono/opentk@b8fd3d2f: Fix Path issue * mono/opentk@62fd3b17: Clean up * mono/opentk@3a1a53c7: Add missing files. Update .gitignore * mono/opentk@e657cf71: Build with dotnet * mono/opentk@6e9a6160: Switch to using Xamarin.Legacy.Sdk * mono/opentk@a46a0668: rework * mono/opentk@cdae43e0: Initial Commit for Building Android Changes: dotnet/android-tools@d92fc3e...c5732a0 * dotnet/android-tools@c5732a0: [Xamarin.Android.Tools.AndroidSdk] Support Microsoft Dist JDK (dotnet#117) * dotnet/android-tools@52ef989: [Xamarin.Android.Tools.AndroidSdk] Fix CS0168 warning (dotnet#116) [0]: https://github.com/xamarin/xamarin-android/commits/d16-10
(Commercial) Xamarin.Android v11.3 is being tracked in the [xamarin-android/d16-10][0] branch, which was branched from commit eac74eb. Bump `$(ProductVersion)` to 11.3.99 to track development progress of the *next* version of Xamarin.Android. Additionally, bump various submodules to their "main" equivalents to mirror the d16-10 branch commit 496a43a, and update `.gitmodules` so that the correct branch name is used: Changes: mono/debugger-libs@8bf09ce...08268b7 * mono/debugger-libs@08268b7: Add Module.ApplyChanges (#342) * mono/debugger-libs@1b5a55a: Fix assembly version after converting projects to SDK style Changes: mono/opentk@933939d...50128f7 * mono/opentk@50128f7a: Create Xamarin.Legacy.OpenTK Nuget Package (#28) * mono/opentk@72f4b085: Merge pull request #26 from dellis1972/ci * mono/opentk@b8fd3d2f: Fix Path issue * mono/opentk@62fd3b17: Clean up * mono/opentk@3a1a53c7: Add missing files. Update .gitignore * mono/opentk@e657cf71: Build with dotnet * mono/opentk@6e9a6160: Switch to using Xamarin.Legacy.Sdk * mono/opentk@a46a0668: rework * mono/opentk@cdae43e0: Initial Commit for Building Android Changes: dotnet/android-tools@d92fc3e...c5732a0 * dotnet/android-tools@c5732a0: [Xamarin.Android.Tools.AndroidSdk] Support Microsoft Dist JDK (#117) * dotnet/android-tools@52ef989: [Xamarin.Android.Tools.AndroidSdk] Fix CS0168 warning (#116) [0]: https://github.com/xamarin/xamarin-android/commits/d16-10
(Commercial) Xamarin.Android v11.3 is being tracked in the [xamarin-android/d16-10][0] branch, which was branched from commit eac74eb. Bump `$(ProductVersion)` to 11.3.99 to track development progress of the *next* version of Xamarin.Android. Additionally, bump various submodules to their "main" equivalents to mirror the d16-10 branch commit 496a43a, and update `.gitmodules` so that the correct branch name is used: Changes: mono/debugger-libs@8bf09ce...08268b7 * mono/debugger-libs@08268b7: Add Module.ApplyChanges (#342) * mono/debugger-libs@1b5a55a: Fix assembly version after converting projects to SDK style Changes: mono/opentk@933939d...50128f7 * mono/opentk@50128f7a: Create Xamarin.Legacy.OpenTK Nuget Package (#28) * mono/opentk@72f4b085: Merge pull request #26 from dellis1972/ci * mono/opentk@b8fd3d2f: Fix Path issue * mono/opentk@62fd3b17: Clean up * mono/opentk@3a1a53c7: Add missing files. Update .gitignore * mono/opentk@e657cf71: Build with dotnet * mono/opentk@6e9a6160: Switch to using Xamarin.Legacy.Sdk * mono/opentk@a46a0668: rework * mono/opentk@cdae43e0: Initial Commit for Building Android Changes: dotnet/android-tools@d92fc3e...c5732a0 * dotnet/android-tools@c5732a0: [Xamarin.Android.Tools.AndroidSdk] Support Microsoft Dist JDK (#117) * dotnet/android-tools@52ef989: [Xamarin.Android.Tools.AndroidSdk] Fix CS0168 warning (#116) [0]: https://github.com/xamarin/xamarin-android/commits/d16-10
We only support ${applicationId} so far, but it seems to be used a lot as
https://developer.android.com/studio/build/manifest-build-variables.html
Since we are not using Gradle, we'd need something similar to it, which
is therefore MSBuild property.