From 3465f6b02b12f18b95f7891267a94258e1941594 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 21 Feb 2018 16:36:10 +0000 Subject: [PATCH] [Xamarin.Android.Build.Tasks] Update `CalculateProjectDependencies` to match spec (#1323) The `GetAndroidDependencies` target (f9b2c972) is intended to be called by an IDE on project-load, so that the IDE can install project dependencies "in the background," and ideally have the dependencies installed before the project is actually built. As such, the semantics of the `@(AndroidDependency)` output item group need to be agreed upon by xamarin-android, the IDEs, and whatever the IDEs use to actually install the dependencies. The `%(AndroidDependency.Identity)` values need to be well-defined and consistent across these three different libraries. In commit f9b2c972, certain values would have a version number "embedded" within `%(AndroidDependency.Identity)`, using a `;` to separate the name from the version, e.g. `build-tools;26.0.1`. Use of `;` was chosen because that made it easier for the package installation code to use (e.g. it would be identical to what the Android SDK `sdkmanager` utility expects). Unfortunately, the use of `;` was counter to the [spec][spec], and also looks "weird" in the context of MSBuild, as `;` is *also* the item group separator. Change the version separator to instead be a `/`. This "looks" better and is also consistent with the [installer manifest][manifest] schema that we will use, wherein `%(AndroidDependency.Identity)` matches a `//xamarin-android/*/@filesystem-path` attribute value: `@(AndroidDependency)` could be equivalent to: 27.0.3 $(AndroidSdkPlatformToolsVersion) 27 $(AndroidSdkToolsVersion) [manifest]: https://gist.github.com/dellis1972/08ba76cc19cdce3dec89c68684664299 [spec]: https://microsoft-my.sharepoint.com/:w:/r/personal/mhutch_microsoft_com/_layouts/15/WopiFrame.aspx?sourcedoc=%7B0436dd38-c9ff-4cf2-b33c-ee4515b68546%7D&action=edit&wdPid=64869a58 --- .../Tasks/CalculateProjectDependencies.cs | 4 ++-- .../GetDependenciesTests.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/CalculateProjectDependencies.cs b/src/Xamarin.Android.Build.Tasks/Tasks/CalculateProjectDependencies.cs index 0d94bca6fe6..b2870a75d07 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/CalculateProjectDependencies.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/CalculateProjectDependencies.cs @@ -51,8 +51,8 @@ public override bool Execute () manifestApiLevel = manifest.TargetSdkVersion ?? manifest.MinSdkVersion ?? DefaultMinSDKVersion; } var sdkVersion = Math.Max (targetApiLevel.Value, manifestApiLevel); - dependencies.Add (CreateAndroidDependency ($"platforms;android-{sdkVersion}", $"")); - dependencies.Add (CreateAndroidDependency ($"build-tools;{BuildToolsVersion}", BuildToolsVersion)); + dependencies.Add (CreateAndroidDependency ($"platforms/android-{sdkVersion}", $"")); + dependencies.Add (CreateAndroidDependency ($"build-tools/{BuildToolsVersion}", BuildToolsVersion)); if (!string.IsNullOrEmpty (PlatformToolsVersion)) { dependencies.Add (CreateAndroidDependency ("platform-tools", PlatformToolsVersion)); } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/GetDependenciesTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/GetDependenciesTests.cs index 2f7f98d6acd..1af4d3ca7d1 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/GetDependenciesTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/GetDependenciesTests.cs @@ -37,11 +37,11 @@ public void CheckNdkBundle ([Values(true, false)] bool ndkRequred) Assert.IsTrue (task.Execute ()); Assert.IsNotNull (task.Dependencies); Assert.AreEqual (ndkRequred ? 5 : 4, task.Dependencies.Length); - Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools;26.0.1" && x.GetMetadata ("Version") == "26.0.1"), + Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools/26.0.1" && x.GetMetadata ("Version") == "26.0.1"), "Dependencies should contains a build-tools version 26.0.1"); Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "tools" && x.GetMetadata ("Version") == "26.0.1"), "Dependencies should contains a tools version 26.0.1"); - Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms;android-26" && x.GetMetadata ("Version") == ""), + Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms/android-26" && x.GetMetadata ("Version") == ""), "Dependencies should contains a platform version android-26"); Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platform-tools" && x.GetMetadata ("Version") == "26.0.3"), "Dependencies should contains a platform-tools version 26.0.3"); @@ -77,11 +77,11 @@ public void ManifestFileDoesNotExist () Assert.IsTrue (task.Execute ()); Assert.IsNotNull (task.Dependencies); Assert.AreEqual (5, task.Dependencies.Length); - Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools;26.0.1" && x.GetMetadata ("Version") == "26.0.1"), + Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools/26.0.1" && x.GetMetadata ("Version") == "26.0.1"), "Dependencies should contains a build-tools version 26.0.1"); Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "tools" && x.GetMetadata ("Version") == "26.0.1"), "Dependencies should contains a tools version 26.0.1"); - Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms;android-26" && x.GetMetadata ("Version") == ""), + Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms/android-26" && x.GetMetadata ("Version") == ""), "Dependencies should contains a platform version android-26"); Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platform-tools" && x.GetMetadata ("Version") == "26.0.3"), "Dependencies should contains a platform-tools version 26.0.3"); @@ -120,11 +120,11 @@ public void ManifestFileExists () Assert.IsTrue(task.Execute ()); Assert.IsNotNull (task.Dependencies); Assert.AreEqual (5, task.Dependencies.Length); - Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools;26.0.1" && x.GetMetadata ("Version") == "26.0.1"), + Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools/26.0.1" && x.GetMetadata ("Version") == "26.0.1"), "Dependencies should contains a build-tools version 26.0.1"); Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "tools" && x.GetMetadata ("Version") == "26.0.1"), "Dependencies should contains a tools version 26.0.1"); - Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms;android-26" && x.GetMetadata ("Version") == ""), + Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms/android-26" && x.GetMetadata ("Version") == ""), "Dependencies should contains a platform version android-26"); Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platform-tools" && x.GetMetadata ("Version") == "26.0.3"), "Dependencies should contains a platform-tools version 26.0.3");