-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] Preserve @(AndroidEnvironment) (#729)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58673 The `@(AndroidEnvironment)` Build action is *supposed to be* usable on Library projects. When used within a Library project, the `@(AndroidEnvironment)` files are embedded into the assembly, and during the App project build they are extracted and merged into the `environment` file within the `.apk`. Unfortunately, this behavior was potentially broken in commit 8688832, as if the Library assembly also contains the `__AndroidLibraryProjects__.zip` embedded resource (e.g. the Library project has a `@(AndroidResource)` Build action), the extraction of the `__AndroidLibraryProjects__.zip` resource will inadvertently remove the previously extracted `@(AndroidEnvironment)` files. Oops. Alter the paths provided to `Files.ExtractAll()` -- which was directly responsible for deleting the environment files -- so that it won't delete the environment files. Update the `tests/locales` on-device unit tests to make use of a Library-provided `@(AndroidEnvironment)`, and add a unit test which reads the environment variable and asserts that the environment variable has the expected value.
- Loading branch information
Showing
5 changed files
with
26 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
THIS_IS_MY_ENVIRONMENT=Well, hello there! |
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
19 changes: 19 additions & 0 deletions
19
tests/locales/Xamarin.Android.Locale-Tests/EnvironmentTests.cs
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace Xamarin.Android.LocaleTests | ||
{ | ||
[TestFixture] | ||
public class EnvironmentTests | ||
{ | ||
[Test (Description="https://bugzilla.xamarin.com/show_bug.cgi?id=58673")] | ||
public void EnvironmentVariablesFromLibraryProjectsAreMerged () | ||
{ | ||
var v = Environment.GetEnvironmentVariable ("THIS_IS_MY_ENVIRONMENT"); | ||
Assert.AreEqual (v, "Well, hello there!"); | ||
} | ||
} | ||
} | ||
|
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