コード例 #1
0
        public static async Task <string> GenerateNuGetConfigIfNeededAsync(string additionalFeed, Version netCoreAppVersion)
        {
            var urls = new List <string>();

            if (!string.IsNullOrEmpty(additionalFeed))
            {
                urls.Add(additionalFeed);
            }

            using (HttpClient client = new HttpClient())
            {
                var nuget       = new NuGet(client);
                var sourceBuild = new SourceBuild(client);
                var prodConUrl  = await GetProdConFeedUrlIfNeededAsync(nuget, sourceBuild, netCoreAppVersion);

                if (!string.IsNullOrEmpty(prodConUrl))
                {
                    prodConUrl = prodConUrl.Trim();
                    Console.WriteLine($"Packages are not live on nuget.org; using {prodConUrl} as additional package source");
                    urls.Add(prodConUrl);
                }

                if (urls.Count != 0)
                {
                    Console.WriteLine("Using nuget sources: " + string.Join(", ", urls));
                    return(nuget.GenerateNuGetConfig(urls));
                }
            }

            return(null);
        }
コード例 #2
0
        public static async Task <string> GetProdConFeedUrlIfNeededAsync(NuGet nuget, SourceBuild sourceBuild, Version netCoreAppVersion)
        {
            bool live = await nuget.IsPackageLiveAsync("runtime.linux-x64.Microsoft.NetCore.DotNetAppHost", netCoreAppVersion);

            if (!live)
            {
                return(await sourceBuild.GetProdConFeedAsync(netCoreAppVersion));
            }

            return(null);
        }