internal static Uri GetCatalogServiceUri(this ServiceIndexResourceV3 serviceIndex, string[] types) { var uris = serviceIndex.GetServiceEntryUris(types); if (uris.Count < 1) { throw new InvalidDataException($"Unable to find a service of type: {string.Join(", ", types)} Verify the index.json file contains this entry."); } return(uris[0]); }
public async Task <string> GetPackageUrl(PackageId packageId, NuGetVersion packageVersion = null, PackageSourceLocation packageSourceLocation = null, bool includePreview = false) { (var source, var resolvedPackageVersion) = await GetPackageSourceAndVerion(packageId, packageVersion, packageSourceLocation, includePreview); SourceRepository repository = GetSourceRepository(source); ServiceIndexResourceV3 serviceIndexResource = repository.GetResourceAsync <ServiceIndexResourceV3>().Result; IReadOnlyList <Uri> packageBaseAddress = serviceIndexResource?.GetServiceEntryUris(ServiceTypes.PackageBaseAddress); return(GetNupkgUrl(packageBaseAddress.First().ToString(), packageId, resolvedPackageVersion)); }
public override int Execute() { if (_printDownloadLinkOnly || !string.IsNullOrWhiteSpace(_fromCacheOption)) { SourceRepository source = Repository.Factory.GetCoreV3("https://www.myget.org/F/mockworkloadfeed/api/v3/index.json"); ServiceIndexResourceV3 serviceIndexResource = source.GetResourceAsync <ServiceIndexResourceV3>().Result; IReadOnlyList <Uri> packageBaseAddress = serviceIndexResource?.GetServiceEntryUris(ServiceTypes.PackageBaseAddress); List <string> allPackageUrl = new List <string>(); if (_printDownloadLinkOnly) { allPackageUrl.Add(nupkgUrl(packageBaseAddress.First().ToString(), "Microsoft.iOS.Bundle", NuGetVersion.Parse("6.0.100"))); allPackageUrl.Add(nupkgUrl(packageBaseAddress.First().ToString(), "Microsoft.NET.Workload.Android", NuGetVersion.Parse("6.0.100"))); Reporter.Output.WriteLine("==allPackageLinksJsonOutputStart=="); Reporter.Output.WriteLine(JsonSerializer.Serialize(allPackageUrl)); Reporter.Output.WriteLine("==allPackageLinksJsonOutputEnd=="); } if (!string.IsNullOrWhiteSpace(_fromCacheOption)) { Directory.CreateDirectory(MockUpdateDirectory); File.Copy(Path.Combine(_fromCacheOption, "Microsoft.NET.Workload.Android.6.0.100.nupkg"), Path.Combine(MockUpdateDirectory, "Microsoft.NET.Workload.Android.6.0.100.nupkg")); File.Copy(Path.Combine(_fromCacheOption, "Microsoft.iOS.Bundle.6.0.100.nupkg"), Path.Combine(MockUpdateDirectory, "Microsoft.iOS.Bundle.6.0.100.nupkg")); } } else { UpdateWorkloads(_includePreviews); } return(0); }
public override int Execute() { // TODO stub Reporter.Output.WriteLine($"WIP workload install {string.Join("; ", _workloadIds)}"); List <string> allowedMockWorkloads = new List <string> { "mobile-ios", "mobile-android" }; if (!_printDownloadLinkOnly && string.IsNullOrWhiteSpace(_fromCacheOption)) { Reporter.Output.WriteLine( "mock currently does not support normal install. Need --print-download-link-only or --from-cache"); } if (_workloadIds.Except(allowedMockWorkloads).Any()) { Reporter.Output.WriteLine("Only support \"mobile-ios\", \"mobile-android\" in the mock"); } SourceRepository source = Repository.Factory.GetCoreV3("https://www.myget.org/F/mockworkloadfeed/api/v3/index.json"); ServiceIndexResourceV3 serviceIndexResource = source.GetResourceAsync <ServiceIndexResourceV3>().Result; IReadOnlyList <Uri> packageBaseAddress = serviceIndexResource?.GetServiceEntryUris(ServiceTypes.PackageBaseAddress); List <string> allPackageUrl = new List <string>(); if (_printDownloadLinkOnly) { if (_workloadIds.Contains("mobile-ios")) { allPackageUrl.Add(nupkgUrl(packageBaseAddress.First().ToString(), "Microsoft.iOS.Bundle", NuGetVersion.Parse("6.0.100"))); AddNewtonsoftJson(allPackageUrl); } if (_workloadIds.Contains("mobile-android")) { allPackageUrl.Add(nupkgUrl(packageBaseAddress.First().ToString(), "Microsoft.NET.Workload.Android", NuGetVersion.Parse("6.0.100"))); AddNewtonsoftJson(allPackageUrl); } Reporter.Output.WriteLine("==allPackageLinksJsonOutputStart=="); Reporter.Output.WriteLine(JsonSerializer.Serialize(allPackageUrl)); Reporter.Output.WriteLine("==allPackageLinksJsonOutputEnd=="); } if (!string.IsNullOrWhiteSpace(_fromCacheOption)) { Directory.CreateDirectory(MockInstallDirectory); if (_workloadIds.Contains("mobile-android")) { File.Copy(Path.Combine(_fromCacheOption, "Microsoft.NET.Workload.Android.6.0.100.nupkg"), Path.Combine(MockInstallDirectory, "Microsoft.NET.Workload.Android.6.0.100.nupkg")); } if (_workloadIds.Contains("mobile-ios")) { File.Copy(Path.Combine(_fromCacheOption, "Microsoft.iOS.Bundle.6.0.100.nupkg"), Path.Combine(MockInstallDirectory, "Microsoft.iOS.Bundle.6.0.100.nupkg")); } } return(0); }