From ee7ce4a799d84ea841099378d2caf2275752f1a5 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 11 Aug 2017 13:45:41 -0400 Subject: [PATCH] [Xamarin.Android.Build.Tasks] Restore @(AndroidEnvironment) We have a failure within `EnvironmentTests.EnvironmentVariablesFromLibraryProjectsAreMerged` (commit ea6b9b45): the `@(AndroidEnvironment)` from the library project is not merged into the App `.apk`: Expected: null But was: "Well, hello there!" (The arguments were in the wrong order. Oops.) The cause for this is due to `` attempts to avoid duplicate work; [from the build log][0] [0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/526/consoleText Task "ResolveLibraryProjectImports" Assemblies: .../xamarin-android/bin/TestDebug//LibraryResources.dll Skipped resource lookup for .../xamarin-android/bin/TestDebug/LibraryResources.dll: extracted files are up to date ResolvedEnvironmentFiles: *Because* `LibraryResources.dll` was skipped, the `@(AndroidEnvironment)` entries from `LibraryResources.dll` were also skipped! Doh! Update the `` task so that when resource extraction for an assembly is skipped, we remember to add the already-extracted `@(AndroidEnvironment)` values. --- .../Tasks/ResolveLibraryProjectImports.cs | 3 +++ tests/locales/Xamarin.Android.Locale-Tests/EnvironmentTests.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs index 8da2ddb3b5d..b7e433143d5 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs @@ -200,6 +200,9 @@ void Extract ( resolvedResourceDirectories.Add (resDir); if (Directory.Exists (assemblyDir)) resolvedAssetDirectories.Add (assemblyDir); + foreach (var env in Directory.EnumerateFiles (importsDir, "__AndroidEnvironment__*", SearchOption.TopDirectoryOnly)) { + resolvedEnvironments.Add (env); + } continue; } diff --git a/tests/locales/Xamarin.Android.Locale-Tests/EnvironmentTests.cs b/tests/locales/Xamarin.Android.Locale-Tests/EnvironmentTests.cs index f22247a6e1b..2c970f56956 100644 --- a/tests/locales/Xamarin.Android.Locale-Tests/EnvironmentTests.cs +++ b/tests/locales/Xamarin.Android.Locale-Tests/EnvironmentTests.cs @@ -12,7 +12,7 @@ public class EnvironmentTests public void EnvironmentVariablesFromLibraryProjectsAreMerged () { var v = Environment.GetEnvironmentVariable ("THIS_IS_MY_ENVIRONMENT"); - Assert.AreEqual (v, "Well, hello there!"); + Assert.AreEqual ("Well, hello there!", v); } } }