Skip to content

Commit 39f0e7f

Browse files
committed
[Xamarin.Android.Build.Tasks] Restore @(AndroidEnvironment) (#742)
We have a failure within `EnvironmentTests.EnvironmentVariablesFromLibraryProjectsAreMerged` (commit ea6b9b4): 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 `<ResolveLibraryProjectImports/>` 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 `<ResolveLibraryProjectImports/>` task so that when resource extraction for an assembly is skipped, we remember to add the already-extracted `@(AndroidEnvironment)` values.
1 parent c5bb33b commit 39f0e7f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ void Extract (
200200
resolvedResourceDirectories.Add (resDir);
201201
if (Directory.Exists (assemblyDir))
202202
resolvedAssetDirectories.Add (assemblyDir);
203+
foreach (var env in Directory.EnumerateFiles (importsDir, "__AndroidEnvironment__*", SearchOption.TopDirectoryOnly)) {
204+
resolvedEnvironments.Add (env);
205+
}
203206
continue;
204207
}
205208

tests/locales/Xamarin.Android.Locale-Tests/EnvironmentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class EnvironmentTests
1212
public void EnvironmentVariablesFromLibraryProjectsAreMerged ()
1313
{
1414
var v = Environment.GetEnvironmentVariable ("THIS_IS_MY_ENVIRONMENT");
15-
Assert.AreEqual (v, "Well, hello there!");
15+
Assert.AreEqual ("Well, hello there!", v);
1616
}
1717
}
1818
}

0 commit comments

Comments
 (0)