private Manifest CreateManifest() { Manifest manifest; ManifestMetadata manifestMetadata; if (!string.IsNullOrEmpty(InputFileName)) { using (var stream = File.OpenRead(InputFileName)) { manifest = Manifest.ReadFrom(stream, false); } if (manifest.Metadata == null) { manifest = new Manifest(new ManifestMetadata(), manifest.Files); } } else { manifest = new Manifest(new ManifestMetadata()); } manifestMetadata = manifest.Metadata; manifestMetadata.UpdateMember(x => x.Authors, Authors?.Split(';')); manifestMetadata.UpdateMember(x => x.Copyright, Copyright); manifestMetadata.UpdateMember(x => x.DependencyGroups, GetDependencySets()); manifestMetadata.UpdateMember(x => x.Description, Description); manifestMetadata.DevelopmentDependency |= DevelopmentDependency; manifestMetadata.UpdateMember(x => x.FrameworkReferences, GetFrameworkAssemblies()); if (IconUrl != null) { manifestMetadata.SetIconUrl(IconUrl); } manifestMetadata.UpdateMember(x => x.Id, Id); manifestMetadata.UpdateMember(x => x.Language, Language); if (LicenseUrl != null) { manifestMetadata.SetLicenseUrl(LicenseUrl); } manifestMetadata.UpdateMember(x => x.MinClientVersionString, MinClientVersion); manifestMetadata.UpdateMember(x => x.Owners, Owners?.Split(';')); if (ProjectUrl != null) { manifestMetadata.SetProjectUrl(ProjectUrl); } manifestMetadata.UpdateMember(x => x.PackageAssemblyReferences, GetReferenceSets()); manifestMetadata.UpdateMember(x => x.ReleaseNotes, ReleaseNotes); manifestMetadata.RequireLicenseAcceptance |= RequireLicenseAcceptance; manifestMetadata.UpdateMember(x => x.Summary, Summary); manifestMetadata.UpdateMember(x => x.Tags, Tags); manifestMetadata.UpdateMember(x => x.Title, Title); manifestMetadata.UpdateMember(x => x.Version, Version != null ? new NuGetVersion(Version) : null); manifestMetadata.UpdateMember(x => x.PackageTypes, GetPackageTypes()); manifestMetadata.Serviceable |= Serviceable; manifest.AddRangeToMember(x => x.Files, GetManifestFiles()); return(manifest); }
private Manifest CreateManifest() { Manifest manifest; ManifestMetadata manifestMetadata; if (!string.IsNullOrEmpty(InputFileName)) { using (var stream = File.OpenRead(InputFileName)) { manifest = Manifest.ReadFrom(stream, false); } if (manifest.Metadata == null) { manifest = new Manifest(new ManifestMetadata(), manifest.Files); } } else { manifest = new Manifest(new ManifestMetadata()); } manifestMetadata = manifest.Metadata; manifestMetadata.UpdateMember(x => x.Authors, Authors?.Split(';')); manifestMetadata.UpdateMember(x => x.Copyright, Copyright); manifestMetadata.UpdateMember(x => x.DependencyGroups, GetDependencySets()); manifestMetadata.UpdateMember(x => x.Description, Description); manifestMetadata.DevelopmentDependency |= DevelopmentDependency; manifestMetadata.UpdateMember(x => x.FrameworkReferences, GetFrameworkAssemblies()); if (!string.IsNullOrEmpty(IconUrl)) { manifestMetadata.SetIconUrl(IconUrl); } if (!string.IsNullOrEmpty(Icon)) { manifestMetadata.Icon = Path.GetFileName(Icon); } manifestMetadata.UpdateMember(x => x.Id, Id); manifestMetadata.UpdateMember(x => x.Language, Language); if (!string.IsNullOrEmpty(PackageLicenseExpression)) { manifestMetadata.LicenseMetadata = new LicenseMetadata( type: LicenseType.Expression, license: PackageLicenseExpression, expression: NuGetLicenseExpression.Parse(PackageLicenseExpression), warningsAndErrors: null, LicenseMetadata.EmptyVersion); } else if (!string.IsNullOrEmpty(LicenseUrl)) { manifestMetadata.SetLicenseUrl(LicenseUrl); } manifestMetadata.Repository = new RepositoryMetadata(RepositoryType ?? "", RepositoryUrl ?? "", RepositoryBranch ?? "", RepositoryCommit ?? ""); manifestMetadata.UpdateMember(x => x.MinClientVersionString, MinClientVersion); manifestMetadata.UpdateMember(x => x.Owners, Owners?.Split(';')); if (!string.IsNullOrEmpty(ProjectUrl)) { manifestMetadata.SetProjectUrl(ProjectUrl); } manifestMetadata.UpdateMember(x => x.PackageAssemblyReferences, GetReferenceSets()); manifestMetadata.UpdateMember(x => x.ReleaseNotes, ReleaseNotes); manifestMetadata.RequireLicenseAcceptance |= RequireLicenseAcceptance; manifestMetadata.UpdateMember(x => x.Summary, Summary); manifestMetadata.UpdateMember(x => x.Tags, Tags); manifestMetadata.UpdateMember(x => x.Title, Title); manifestMetadata.UpdateMember(x => x.Version, Version != null ? new NuGetVersion(Version) : null); manifestMetadata.UpdateMember(x => x.PackageTypes, GetPackageTypes()); manifestMetadata.Serviceable |= Serviceable; manifest.AddRangeToMember(x => x.Files, GetManifestFiles()); return(manifest); }
private PackageBuilder CreatePackage() { PackageBuilder pb = new PackageBuilder(); pb.Id = Id; pb.Version = new SemanticVersion(Version); pb.Title = Title; pb.Description = Description; pb.Authors.AddRange(Authors.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)); pb.Owners.AddRange(Owners.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)); if (FrameworkAssemblies != null) { foreach (var fa in FrameworkAssemblies) { pb.FrameworkReferences.Add(new FrameworkAssemblyReference(fa.FrameworkName)); } } if (Dependencies != null) { var groups = new Dictionary <string, List <NuGetDependency> >(); foreach (var dpg in Dependencies) { string framework = dpg.TargetFramework; if (String.IsNullOrWhiteSpace(framework)) { framework = ""; } List <NuGetDependency> list; if (!groups.TryGetValue(framework, out list)) { groups[framework] = list = new List <NuGetDependency>(); } list.AddRange(dpg.Dependencies); } foreach (var g in groups) { FrameworkName fn = g.Key == "" ? null : VersionUtility.ParseFrameworkName(g.Key); PackageDependencySet ds = new PackageDependencySet(fn, g.Value.Select(v => (PackageDependency)v)); pb.DependencySets.Add(ds); } } if (Icon != null) { pb.IconUrl = Icon; } if (Url != null) { pb.ProjectUrl = Url; } if (License != null) { pb.LicenseUrl = License; } if (Summary != null) { pb.Summary = Summary; } if (Copyright != null) { pb.Copyright = Copyright; } if (ReleaseNotes != null) { pb.ReleaseNotes = ReleaseNotes; } return(pb); }