コード例 #1
0
ファイル: PackageSourceUtils.cs プロジェクト: cemoses/aspnet
        public static IPackageFeed CreatePackageFeed(PackageSource source, bool noCache, bool ignoreFailedSources,
            Reports reports)
        {
            // Check if the feed is a URL
            if (source.IsLocalFileSystem())
            {
                return PackageFolderFactory.CreatePackageFolderFromPath(source.Source, ignoreFailedSources, reports);
            }
            else
            {
                var httpSource = new HttpSource(
                    source.Source,
                    source.UserName,
                    source.Password,
                    reports);

                Uri packageBaseAddress;
                if (NuGetv3Feed.DetectNuGetV3(httpSource, noCache, out packageBaseAddress))
                {
                    if (packageBaseAddress == null)
                    {
                        reports.Information.WriteLine(
                            $"Ignoring NuGet v3 feed {source.Source.Yellow().Bold()}, which doesn't provide PackageBaseAddress resource.");
                        return null;
                    }

                    httpSource = new HttpSource(
                        packageBaseAddress.AbsoluteUri,
                        source.UserName,
                        source.Password,
                        reports);

                    return new NuGetv3Feed(
                        httpSource,
                        noCache,
                        reports,
                        ignoreFailedSources);
                }

                return new NuGetv2Feed(
                    httpSource,
                    noCache,
                    reports,
                    ignoreFailedSources);
            }
        }
コード例 #2
0
ファイル: PackageFeedCache.cs プロジェクト: yossidev/dnx
        private IPackageFeed CreatePackageFeed(PackageSource source, bool noCache, bool ignoreFailedSources,
                                               Reports reports)
        {
            // Check if the feed is a file path
            if (source.IsLocalFileSystem())
            {
                return(PackageFolderFactory.CreatePackageFolderFromPath(source.Source, ignoreFailedSources, reports));
            }
            else
            {
                var httpSource = new HttpSource(
                    source.Source,
                    source.UserName,
                    source.Password,
                    reports);

                Uri packageBaseAddress;
                if (NuGetv3Feed.DetectNuGetV3(httpSource, noCache, out packageBaseAddress))
                {
                    if (packageBaseAddress == null)
                    {
                        reports.Information.WriteLine(
                            $"Ignoring NuGet v3 feed {source.Source.Yellow().Bold()}, which doesn't provide PackageBaseAddress resource.");
                        return(null);
                    }

                    httpSource = new HttpSource(
                        packageBaseAddress.AbsoluteUri,
                        source.UserName,
                        source.Password,
                        reports);

                    return(new NuGetv3Feed(
                               httpSource,
                               noCache,
                               reports,
                               ignoreFailedSources));
                }

                return(new NuGetv2Feed(
                           httpSource,
                           noCache,
                           reports,
                           ignoreFailedSources));
            }
        }