Ejemplo n.º 1
0
        public override void AddPackage(IPackage package)
        {
            if (PackageSaveMode.HasFlag(PackageSaveModes.Nuspec))
            {
                // Starting from 2.1, we save the nuspec file into the subdirectory with the name as <packageId>.<version>
                // for example, for jQuery version 1.0, it will be "jQuery.1.0\\jQuery.1.0.nuspec"
                string   packageFilePath = GetManifestFilePath(package.Id, package.Version);
                Manifest manifest        = Manifest.Create(package);

                // The IPackage object doesn't carry the References information.
                // Thus we set the References for the manifest to the set of all valid assembly references
                manifest.Metadata.ReferenceSets = package.AssemblyReferences
                                                  .GroupBy(f => f.TargetFramework)
                                                  .Select(
                    g => new ManifestReferenceSet
                {
                    TargetFramework = g.Key == null ? null : VersionUtility.GetFrameworkString(g.Key),
                    References      = g.Select(p => new ManifestReference {
                        File = p.Name
                    }).ToList()
                })
                                                  .ToList();

                FileSystem.AddFileWithCheck(packageFilePath, manifest.Save);
            }

            if (PackageSaveMode.HasFlag(PackageSaveModes.Nupkg))
            {
                string packageFilePath = GetPackageFilePath(package);

                FileSystem.AddFileWithCheck(packageFilePath, package.GetStream);
            }
        }
        public override void AddPackage(IPackage package)
        {
            string packageFilePath = GetPackageFilePath(package);

            if (PackageSaveMode.HasFlag(PackageSaveModes.Nuspec))
            {
                string   manifestFilePath = GetManifestFilePath(package.Id, package.Version);
                Manifest manifest         = Manifest.Create(package);
                manifest.Metadata.ReferenceSets = Enumerable.ToList <ManifestReferenceSet>(Enumerable.Select <IGrouping <FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>(Enumerable.GroupBy <IPackageAssemblyReference, FrameworkName>(package.AssemblyReferences, (Func <IPackageAssemblyReference, FrameworkName>)(f => f.TargetFramework)), (Func <IGrouping <FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>)(g => new ManifestReferenceSet()
                {
                    TargetFramework = g.Key == (FrameworkName)null ? (string)null : VersionUtility.GetFrameworkString(g.Key),
                    References      = Enumerable.ToList <ManifestReference>(Enumerable.Select <IPackageAssemblyReference, ManifestReference>((IEnumerable <IPackageAssemblyReference>)g, (Func <IPackageAssemblyReference, ManifestReference>)(p => new ManifestReference()
                    {
                        File = p.Name
                    })))
                })));
                FileSystem.AddFileWithCheck(manifestFilePath, manifest.Save);
            }

            FileSystem.AddFileWithCheck(packageFilePath, package.GetStream);
        }
Ejemplo n.º 3
0
        public override void AddPackage(IPackage package)
        {
            string packageFilePath = GetPackageFilePath(package);

            FileSystem.AddFileWithCheck(packageFilePath, package.GetStream);
            // allow the file to finish being written
            Thread.Sleep(200);
            if (PackageSaveMode.HasFlag(PackageSaveModes.Nuspec))
            {
                // don't trust the package metadata to be complete - extract from the downloaded nupkg
                var      zipPackage       = new OptimizedZipPackage(FileSystem, packageFilePath);
                string   manifestFilePath = GetManifestFilePath(package.Id, package.Version);
                Manifest manifest         = Manifest.Create(zipPackage);
                manifest.Metadata.ReferenceSets = Enumerable.ToList <ManifestReferenceSet>(Enumerable.Select <IGrouping <FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>(Enumerable.GroupBy <IPackageAssemblyReference, FrameworkName>(package.AssemblyReferences, (Func <IPackageAssemblyReference, FrameworkName>)(f => f.TargetFramework)), (Func <IGrouping <FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>)(g => new ManifestReferenceSet()
                {
                    TargetFramework = g.Key == (FrameworkName)null ? (string)null : VersionUtility.GetFrameworkString(g.Key),
                    References      = Enumerable.ToList <ManifestReference>(Enumerable.Select <IPackageAssemblyReference, ManifestReference>((IEnumerable <IPackageAssemblyReference>)g, (Func <IPackageAssemblyReference, ManifestReference>)(p => new ManifestReference()
                    {
                        File = p.Name
                    })))
                })));
                FileSystem.AddFileWithCheck(manifestFilePath, manifest.Save);
            }
        }