internal static SdkInfo[] LoadConfig(string file) { if (!File.Exists(file)) { return(new SdkInfo [0]); } var sdks = new List <SdkInfo> (); using (var sr = new StreamReader(file)) { string line; while ((line = sr.ReadLine()) != null) { var sdkInfo = new SdkInfo(); int i = line.IndexOf(':'); sdkInfo.Path = line.Substring(i + 1); var sdk = line.Substring(0, i); i = sdk.IndexOf(','); sdkInfo.Name = sdk.Substring(0, i); var ver = sdk.Substring(i + 1); if (ver.Length > 0) { SdkVersion.TryParse(ver, out SdkVersion v); sdkInfo.Version = v; } sdks.Add(sdkInfo); } } return(sdks.ToArray()); }
public override SdkResult Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory) { SdkVersion.TryParse(sdkReference.MinimumVersion, out SdkVersion minVersion); SdkInfo bestSdk = null; // Pick the SDK with the highest version foreach (var sdk in sdkFetcher()) { if (StringComparer.OrdinalIgnoreCase.Equals(sdk.Name, sdkReference.Name)) { if (sdk.Version != null) { // If the sdk has a version, it must satisfy the min version requirement if (minVersion != null && sdk.Version < minVersion) { continue; } if (bestSdk?.Version == null || bestSdk.Version < sdk.Version) { bestSdk = sdk; } } else { // Pick this sdk for now, even if it has no version info if (bestSdk == null) { bestSdk = sdk; } } } } if (bestSdk != null) { return(factory.IndicateSuccess(bestSdk.Path, bestSdk.Version?.ToString())); } else { return(factory.IndicateFailure(new string [] { "SDK not found" })); } }
public SdkInfo(string name, SdkVersion version, string path) { Name = name; Version = version; Path = path; }