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

[msbuild] support AndroidManifest.xml placeholders. #342

Merged
merged 1 commit into from
Feb 6, 2017

Conversation

atsushieno
Copy link
Contributor

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.

@@ -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; }
Copy link
Member

@jonpryor jonpryor Dec 28, 2016

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.

Copy link
Contributor Author

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 ('='))) {
Copy link
Member

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)

@@ -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 ('='))) {
Copy link
Member

@jonpryor jonpryor Jan 9, 2017

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)).

@jonpryor
Copy link
Member

jonpryor commented Jan 9, 2017

We should probably have a test for this as well, perhaps by using src/Mono.Android/Test/Mono.Android-Tests.csproj and src/Mono.Android/Test/Properties/AndroidManifest.xml, and possibly a [Test] that checks the value of...whatever was added to AndroidManifest.xml.

@atsushieno
Copy link
Contributor Author

A corresponding test is being added to our msbuild tests (which should become public too).

@atsushieno
Copy link
Contributor Author

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.
@jonpryor jonpryor merged commit b423ff6 into dotnet:master Feb 6, 2017
@jzeferino
Copy link

jzeferino commented Mar 21, 2017

Is this PR released in any Xamarin android version?

@jonpryor
Copy link
Member

@jzeferino: It's in Xamarin.Android 7.2, currently in the Beta channel.

jonpryor added a commit that referenced this pull request Apr 26, 2021
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)
jonpryor added a commit that referenced this pull request Apr 26, 2021
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)
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Apr 26, 2021
(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
jonpryor added a commit that referenced this pull request Apr 27, 2021
(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
jonathanpeppers pushed a commit that referenced this pull request Apr 27, 2021
(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
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants