public override void AddPackage(IPackage package) { // 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); 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.References = package.AssemblyReferences .Select(p => new ManifestReference() { File = p.Name }) .Distinct() .ToList(); FileSystem.AddFileWithCheck(packageFilePath, stream => manifest.Save(stream)); // But in order to maintain backwards compatibility with older versions of NuGet, // we will save the .nupkg file too. This way, 2.1 will read the .nuspec file, and // pre 2.1 will read the .nupkg base.AddPackage(package); }
public override void AddPackage(IPackage package) { // 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); // But in order to maintain backwards compatibility with older versions of NuGet, // we will save the .nupkg file too. This way, 2.1 will read the .nuspec file, and // pre 2.1 will read the .nupkg base.AddPackage(package); // if this is a solution-level package, add it to the solution's packages.config file if (_packageReferenceFile != null && IsSolutionLevel(package)) { _packageReferenceFile.AddEntry(package.Id, package.Version); } }
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); }
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); } }
public override void AddPackage(IPackage package) { string packageFilePath = GetPackageFilePath(package); FileSystem.AddFileWithCheck(packageFilePath, package.GetStream); }