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) { 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) { // 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) { if (base.PackageSaveMode.HasFlag(PackageSaveModes.Nuspec)) { string manifestFilePath = this.GetManifestFilePath(package.Id, package.Version); Manifest manifest = Manifest.Create(package); manifest.Metadata.ReferenceSets = Enumerable.Select <IGrouping <FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>(from f in package.AssemblyReferences group f by f.TargetFramework, delegate(IGrouping <FrameworkName, IPackageAssemblyReference> g) { ManifestReferenceSet set1 = new ManifestReferenceSet(); ManifestReferenceSet set2 = new ManifestReferenceSet(); set2.TargetFramework = (g.Key == null) ? null : VersionUtility.GetFrameworkString(g.Key); ManifestReferenceSet local2 = set2; ManifestReferenceSet local3 = set2; local3.References = Enumerable.Select <IPackageAssemblyReference, ManifestReference>(g, delegate(IPackageAssemblyReference p) { ManifestReference reference1 = new ManifestReference(); reference1.File = p.Name; return(reference1); }).ToList <ManifestReference>(); return(local3); }).ToList <ManifestReferenceSet>(); this.FileSystem.AddFileWithCheck(manifestFilePath, new Action <Stream>(manifest.Save)); } if (base.PackageSaveMode.HasFlag(PackageSaveModes.Nupkg)) { string packageFilePath = this.GetPackageFilePath(package); this.FileSystem.AddFileWithCheck(packageFilePath, new Func <Stream>(package.GetStream)); } }
private void WriteManifest(Package package, int minimumManifestVersion) { Uri targetUri = UriUtility.CreatePartUri(this.Id + Constants.ManifestExtension); package.CreateRelationship(targetUri, TargetMode.Internal, "http://schemas.microsoft.com/packaging/2010/07/manifest"); using (Stream stream = package.CreatePart(targetUri, "application/octet", CompressionOption.Maximum).GetStream()) { Manifest.Create(this).Save(stream, minimumManifestVersion); } }
private void WriteManifest(ZipArchive package, int minimumManifestVersion) { string path = Id + Constants.ManifestExtension; WriteOpcManifestRelationship(package, path); ZipArchiveEntry entry = package.CreateEntry(path, CompressionLevel.Optimal); using (Stream stream = entry.Open()) { Manifest manifest = Manifest.Create(this); manifest.Save(stream, minimumManifestVersion); } }
private void WriteManifest(Package package) { Uri uri = UriUtility.CreatePartUri(Id + Constants.ManifestExtension); // Create the manifest relationship package.CreateRelationship(uri, TargetMode.Internal, Constants.SchemaNamespace + ManifestRelationType); // Create the part PackagePart packagePart = package.CreatePart(uri, DefaultContentType, CompressionOption.Maximum); using (Stream stream = packagePart.GetStream()) { Manifest manifest = Manifest.Create(this); manifest.Save(stream); } }
private void WriteManifest(System.IO.Packaging.Package package, int minimumManifestVersion) { Uri uri = UriUtility.CreatePartUri(Id + Constants.ManifestExtension); // Create the manifest relationship package.CreateRelationship(uri, System.IO.Packaging.TargetMode.Internal, Constants.PackageRelationshipNamespace + ManifestRelationType); // Create the part var packagePart = package.CreatePart(uri, DefaultContentType, System.IO.Packaging.CompressionOption.Maximum); using (Stream stream = packagePart.GetStream()) { Manifest manifest = Manifest.Create(this); manifest.Save(stream, minimumManifestVersion); } }
private void WriteManifest(Package package, int minimumManifestVersion) { Uri uri = UriUtility.CreatePartUri(Id + Constants.ManifestExtension); // Create the manifest relationship package.CreateRelationship(uri, TargetMode.Internal, Constants.PackageRelationshipNamespace + ManifestRelationType); // Create the part PackagePart packagePart = package.CreatePart(uri, DefaultContentType, CompressionOption.Maximum); using (Stream stream = packagePart.GetStream()) { Manifest manifest = Manifest.Create(this); //if (PackageAssemblyReferences.Any()) //{ // manifest.Metadata.References = new List<ManifestReference>( // PackageAssemblyReferences.Select(reference => new ManifestReference {File = reference.File})); //} manifest.Save(stream, minimumManifestVersion); } }