public bool BuildPackage(IEnumerable <ProjectContext> contexts, List <DiagnosticMessage> packDiagnostics) { Reporter.Output.WriteLine($"Producing nuget package \"{GetPackageName()}\" for {Project.Name}"); PackageBuilder = CreatePackageBuilder(Project); // TODO: Report errors for required fields // id // author // description foreach (var context in contexts) { Reporter.Verbose.WriteLine($"Processing {context.TargetFramework.ToString().Yellow()}"); ProcessContext(context); Reporter.Verbose.WriteLine(""); } var packageOutputPath = Path.Combine( ArtifactPathsCalculator.PackageOutputPath, GetPackageName() + NuGetConstants.PackageExtension); if (GeneratePackage(packageOutputPath, packDiagnostics)) { return(true); } return(false); }
private static PackageBuilder CreatePackageBuilder(Project project) { var builder = new PackageBuilder(); builder.Authors.AddRange(project.Authors); builder.Owners.AddRange(project.PackOptions.Owners); if (builder.Authors.Count == 0) { var defaultAuthor = Environment.GetEnvironmentVariable("NUGET_AUTHOR"); if (string.IsNullOrEmpty(defaultAuthor)) { builder.Authors.Add(project.Name); } else { builder.Authors.Add(defaultAuthor); } } builder.Description = project.Description ?? project.Name; builder.Id = project.Name; builder.Version = project.Version; builder.Title = project.Title; builder.Summary = project.PackOptions.Summary; builder.Copyright = project.Copyright; builder.RequireLicenseAcceptance = project.PackOptions.RequireLicenseAcceptance; builder.ReleaseNotes = project.PackOptions.ReleaseNotes; builder.Language = project.Language; builder.Tags.AddRange(project.PackOptions.Tags); builder.Serviceable = project.Serviceable; if (!string.IsNullOrEmpty(project.PackOptions.IconUrl)) { builder.IconUrl = new Uri(project.PackOptions.IconUrl); } if (!string.IsNullOrEmpty(project.PackOptions.ProjectUrl)) { builder.ProjectUrl = new Uri(project.PackOptions.ProjectUrl); } if (!string.IsNullOrEmpty(project.PackOptions.LicenseUrl)) { builder.LicenseUrl = new Uri(project.PackOptions.LicenseUrl); } return(builder); }