private static string GenerateMainPackage(string userDefinedPrefix,
                                              [NotNull] string productName,
                                              [NotNull] IEnumerable<FileInfo> files,
                                              [NotNull] string releaseFolderPath,
                                              [NotNull] string releaseVersion,
                                              [NotNull] string releaseTitle)
        {
            Assert.ArgumentNotNull(files, "files");
              Assert.ArgumentNotNull(releaseFolderPath, "releaseFolderPath");
              Assert.ArgumentNotNull(releaseVersion, "releaseVersion");
              Assert.ArgumentNotNull(releaseTitle, "releaseTitle");

              var dependencies = files.Select(x => new ManifestDependency { Id = GetNuGetName(x.FullName, userDefinedPrefix), Version = releaseVersion });

              var packageName = GetPrefix(productName).TrimEnd('.');

              var metadata = new ManifestMetadata
              {
            Id = packageName,
            Version = releaseVersion,
            Authors = "Sitecore",
            Description = "All assemblies of Sitecore " + releaseTitle,
            RequireLicenseAcceptance = false,
            DependencySets = new List<ManifestDependencySet>
            {
              new ManifestDependencySet
              {
            Dependencies = dependencies.ToList()
              }
            }
              };

              var builder = new PackageBuilder();

              builder.Populate(metadata);
              var nugetFilePath = Path.Combine(releaseFolderPath, metadata.Id + "." + releaseVersion + ".nupkg");
              using (FileStream stream = File.Open(nugetFilePath, FileMode.OpenOrCreate))
              {
            builder.Save(stream);
              }

              return nugetFilePath;
        }
        private static string GenerateFilesPackage(string userDefinedPrefix,
                                               [NotNull] string productName,
                                               [NotNull] IEnumerable<FileInfo> files,
                                               [NotNull] string releaseFolderPath,
                                               [NotNull] string releaseVersion,
                                               [NotNull] string releaseTitle)
        {
            Assert.ArgumentNotNull(files, "files");
              Assert.ArgumentNotNull(releaseFolderPath, "releaseFolderPath");
              Assert.ArgumentNotNull(releaseVersion, "releaseVersion");
              Assert.ArgumentNotNull(releaseTitle, "releaseTitle");

              string packageName = GetPrefix(productName).TrimEnd('.') + "-AsFiles";

              var metadata = new ManifestMetadata
              {
            Id = packageName,
            Version = releaseVersion,
            Authors = "Sitecore",
            Description = "All assemblies of Sitecore " + releaseTitle + " as content files in /App_Data/bin folder",
            RequireLicenseAcceptance = false
              };

              var builder = new PackageBuilder();

              foreach (var assembly in files)
              {
            var assemblyFilePath = assembly.FullName;
            builder.Files.Add(new PhysicalPackageFile
            {
              SourcePath = assemblyFilePath,
              TargetPath = "content\\App_Bin\\" + Path.GetFileName(assemblyFilePath)
            });
              }

              builder.Populate(metadata);

              var nugetFilePath = Path.Combine(releaseFolderPath, metadata.Id + "." + releaseVersion + ".nupkg");
              using (FileStream stream = File.Open(nugetFilePath, FileMode.OpenOrCreate))
              {
            builder.Save(stream);
              }

              return nugetFilePath;
        }
        private static string GenerateLinksPackage(string userDefinedPrefix,
                                               [NotNull] string productName,
                                               [NotNull] IEnumerable<FileInfo> files,
                                               [NotNull] string releaseFolderPath,
                                               [NotNull] string releaseVersion,
                                               [NotNull] string releaseTitle)
        {
            Assert.ArgumentNotNull(productName, "productName");
              Assert.ArgumentNotNull(files, "files");
              Assert.ArgumentNotNull(releaseFolderPath, "releaseFolderPath");
              Assert.ArgumentNotNull(releaseVersion, "releaseVersion");
              Assert.ArgumentNotNull(releaseTitle, "releaseTitle");

              var installPs1 = Path.GetTempFileName();
              var uninstallPs1 = Path.GetTempFileName();
              try
              {
            File.WriteAllText(installPs1, InstallPs1);
            File.WriteAllText(uninstallPs1, UninstallPs1);

            string packageName = GetPrefix(productName).TrimEnd('.') + "-AsLinks";

            var metadata = new ManifestMetadata
            {
              Id = packageName,
              Version = releaseVersion,
              Authors = "Sitecore",
              Description = "All assemblies of Sitecore " + releaseTitle + " as links to ../packages/SC.{ver}/*.dll in /App_Data/bin folder",
              RequireLicenseAcceptance = false
            };

            var builder = new PackageBuilder();

            foreach (var assembly in files)
            {
              var assemblyFilePath = assembly.FullName;
              builder.Files.Add(new PhysicalPackageFile
              {
            SourcePath = assemblyFilePath,
            TargetPath = "App_Bin\\" + Path.GetFileName(assemblyFilePath)
              });
            }

            builder.Files.Add(new PhysicalPackageFile
            {
              SourcePath = installPs1,
              TargetPath = "tools\\install.ps1"
            });

            builder.Files.Add(new PhysicalPackageFile
            {
              SourcePath = uninstallPs1,
              TargetPath = "tools\\uninstall.ps1"
            });

            builder.Populate(metadata);

            var nugetFilePath = Path.Combine(releaseFolderPath, metadata.Id + "." + releaseVersion + ".nupkg");
            using (FileStream stream = File.Open(nugetFilePath, FileMode.OpenOrCreate))
            {
              builder.Save(stream);
            }

            return nugetFilePath;
              }
              finally
              {
            if (File.Exists(installPs1))
            {
              File.Delete(installPs1);
            }

            if (File.Exists(uninstallPs1))
            {
              File.Delete(uninstallPs1);
            }
              }
        }
        public virtual string GenerateSingleAssemblyPackage(string userDefinedPrefix,
                                                   [NotNull] string assemblyFilePath,
                                                   [NotNull] string releaseFolderPath,
                                                   [NotNull] string releaseVersion,
                                                   [NotNull] string releaseTitle)
        {
            Assert.ArgumentNotNull(assemblyFilePath, "assemblyFilePath");
              Assert.ArgumentNotNull(releaseFolderPath, "releaseFolderPath");
              Assert.ArgumentNotNull(releaseVersion, "releaseVersion");
              Assert.ArgumentNotNull(releaseTitle, "releaseTitle");

              var version = FileVersionInfo.GetVersionInfo(assemblyFilePath);
              var nugetName = GetNuGetName(assemblyFilePath, userDefinedPrefix);

              var metadata = new ManifestMetadata
              {
            Id = nugetName,
            Version = releaseVersion,
            Authors = "Sitecore",
            RequireLicenseAcceptance = false,
            Description = string.Format("{0} assembly of {1}, assembly file version: {2}, product version: {3}", nugetName, releaseTitle, version.FileVersion, version.ProductVersion),
              };

              var builder = new PackageBuilder();

              builder.Files.Add(new PhysicalPackageFile
              {
            SourcePath = assemblyFilePath,
            TargetPath = "lib\\" + Path.GetFileName(assemblyFilePath)
              });

              var copyLocalInstallPs1 = Path.GetTempFileName();
              File.WriteAllText(copyLocalInstallPs1, CopyLocalInstallPs1);
              builder.Files.Add(new PhysicalPackageFile
              {
            SourcePath = copyLocalInstallPs1,
            TargetPath = "tools\\install.ps1"
              });

              builder.Populate(metadata);

              var nugetFilePath = Path.Combine(releaseFolderPath, metadata.Id + "." + releaseVersion + ".nupkg");
              this.Save(builder, nugetFilePath);

              return nugetFilePath;
        }