Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 496d206

Browse files
authored
Remove NuGet lookup from target
We initially tried to do a nice thing of, go find the latest version of android support libraries on nuget for a given api level if we wanted to recommend a version to use. This proved to increase build times more often than we'd like. Given that support libraries are winding down anyway, I don't think this is very relevant or important anymore.
1 parent 2cb0880 commit 496d206

File tree

1 file changed

+1
-68
lines changed

1 file changed

+1
-68
lines changed

source/buildtasks/support-annotations/NugetPackages.cs

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace Xamarin.Android.Support.BuildTasks
1616
{
1717
public static class NugetPackages
1818
{
19-
const int WEB_REQUEST_TIMEOUT_MS = 10000;
20-
2119
public static readonly Dictionary<int, Version> AndroidApiLevelsAndVersions = new Dictionary<int, Version>
2220
{
2321
{ 23, new Version(6, 0) },
@@ -130,71 +128,6 @@ public static string GetSupportVersion(string packageIdPrefix, Dictionary<string
130128
}
131129

132130
public static string GetRecommendedSupportPackageVersion(int apiLevel, bool skipNugetQuery)
133-
{
134-
// Default to the apilevel.x since this is displayed as a suggestion in a message
135-
var bestVersion = apiLevel.ToString() + ".*";
136-
137-
// If we should skip an http request to nuget.org just return the api level
138-
if (skipNugetQuery)
139-
return bestVersion;
140-
141-
try
142-
{
143-
var searchUrl = GetNuGetSearchUrl();
144-
145-
var queryUrl = searchUrl + "?q=packageid:Xamarin.Android.Support.Annotations&prerelease=false";
146-
147-
var data = DownloadString(queryUrl);
148-
149-
var js = new JavaScriptSerializer();
150-
var json = js.Deserialize<dynamic>(data);
151-
152-
var versions = json["data"][0]["versions"];
153-
154-
foreach (var version in versions)
155-
{
156-
var v = version["version"].ToString();
157-
158-
if (v.StartsWith(apiLevel.ToString() + ".", StringComparison.InvariantCultureIgnoreCase))
159-
bestVersion = v;
160-
}
161-
} catch (Exception ex) {
162-
Console.WriteLine(ex);
163-
}
164-
165-
return bestVersion;
166-
}
167-
168-
static string GetNuGetSearchUrl()
169-
{
170-
var data = DownloadString("https://api.nuget.org/v3/index.json");
171-
172-
var js = new JavaScriptSerializer();
173-
var json = js.Deserialize<dynamic>(data);
174-
175-
foreach (var item in json["resources"]) {
176-
if (item["@type"] == "SearchQueryService")
177-
return item["@id"];
178-
}
179-
180-
return null;
181-
}
182-
183-
static string DownloadString(string url)
184-
{
185-
var result = string.Empty;
186-
187-
var request = WebRequest.CreateHttp(url);
188-
request.Timeout = WEB_REQUEST_TIMEOUT_MS;
189-
request.ReadWriteTimeout = WEB_REQUEST_TIMEOUT_MS;
190-
191-
using (var response = (HttpWebResponse)request.GetResponse())
192-
using (var respStream = response.GetResponseStream())
193-
using (var sr = new StreamReader(respStream)) {
194-
result = sr.ReadToEnd();
195-
}
196-
197-
return result;
198-
}
131+
=> apiLevel.ToString() + ".*";
199132
}
200133
}

0 commit comments

Comments
 (0)