当前位置: 首页>>代码示例>>C#>>正文


C# PackageBuilder.PopulateFiles方法代码示例

本文整理汇总了C#中NuGet.PackageBuilder.PopulateFiles方法的典型用法代码示例。如果您正苦于以下问题:C# PackageBuilder.PopulateFiles方法的具体用法?C# PackageBuilder.PopulateFiles怎么用?C# PackageBuilder.PopulateFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NuGet.PackageBuilder的用法示例。


在下文中一共展示了PackageBuilder.PopulateFiles方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Create NuGet Package via Code");
            ManifestMetadata metadata = new ManifestMetadata()
            {
                Authors = "Authors Name",
                Version = "1.0.0.0",
                Id = "NuGetId",
                Description = "NuGet Package Description goes here!",
            };

            PackageBuilder builder = new PackageBuilder();


            var path = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\DemoContent\\";

            builder.PopulateFiles(path, new[] { new ManifestFile { Source = "**", Target = "content" } });
            builder.Populate(metadata);

            using (FileStream stream = File.Open("test.nupkg", FileMode.OpenOrCreate))
            {
                builder.Save(stream);
            }

            Console.WriteLine("... and extract NuGet Package via Code");

            NuGet.ZipPackage package = new ZipPackage("test.nupkg");
            var content = package.GetContentFiles();

            Console.WriteLine("Package Id: " + package.Id);
            Console.WriteLine("Content-Files-Count: " + content.Count());

            Console.ReadLine();
        }
开发者ID:ledgarl,项目名称:Samples,代码行数:34,代码来源:Program.cs

示例2: BuildPackage

 public void BuildPackage(string baseUrl, ManifestMetadata metadata, ManifestFile[] files)
 {
     NuGet.PackageBuilder packageBuilder = new NuGet.PackageBuilder();
     packageBuilder.Populate(metadata);
     packageBuilder.PopulateFiles(baseUrl, files);
     var saveDir = Path.Combine(DEFAULT_PACKAGES_SAVE_PATH, packageBuilder.Id, packageBuilder.Version.ToString().Replace('.', '_'));
     Directory.CreateDirectory(saveDir);
     var saveStream = File.Create(Path.Combine(saveDir, packageBuilder.Id + ".nupkg"));
     packageBuilder.Save(saveStream);
 }
开发者ID:MichaelSL,项目名称:nugetbuilder,代码行数:10,代码来源:PackageBuilder.cs

示例3: BuildPackage

        public void BuildPackage(string basePath, IList<string> includes, ManifestMetadata metadata, string outFolder, bool overwrite)
        {
            var package = new PackageBuilder();

            package.PopulateFiles(basePath, includes.Select(i => new ManifestFile { Source = i }));
            package.Populate(metadata);

            var filename = metadata.Id + "." + metadata.Version + ".nupkg";
            var output = Path.Combine(outFolder, filename);

            if (fileSystem.FileExists(output) && !overwrite)
                throw new CommandException("The package file already exists and --overwrite was not specified");

            log.InfoFormat("Saving {0} to {1}...", filename, outFolder);

            fileSystem.EnsureDirectoryExists(outFolder);

            using (var outStream = fileSystem.OpenFile(output, FileMode.Create))
                package.Save(outStream);
        }
开发者ID:rodrickyu,项目名称:Octopus-Tools,代码行数:20,代码来源:NuGetPackageBuilder.cs

示例4: ManifestMetadata

        IPackage IPackageFactory.CreateFromProject(string nupecFile, string csprojFile, string buildConfiguration, bool includeBinOutput)
        {
            var projectReader = _projectReaderFactory.Create(csprojFile);
            var binDir = projectReader.GetBinPath(buildConfiguration);
            var assemblyName = projectReader.GetAssemblyName();
            var assemblyPath = _fileSystem.CombinePaths(binDir, assemblyName);
            var assemblyReader = _assemblyReaderFactory.Create(assemblyPath);

            var manifest = new ManifestMetadata()
            {
                Id = assemblyReader.GetPackageId(),
                Title = assemblyReader.GetPackageTitle(),
                Owners = assemblyReader.GetCompany(),
                Authors = assemblyReader.GetCompany(),
                Description = assemblyReader.GetDescription(),
                Copyright = assemblyReader.GetCopyright(),
                Version = assemblyReader.GetFileVersion()
            };

            var files = new List<ManifestFile>();
            foreach (var dll in _fileSystem.FindFiles(binDir, "*.dll", false))
                files.Add(new ManifestFile() { Source = dll, Target = @"lib\net40" });

            var packageBuilder = new PackageBuilder();
            packageBuilder.Populate(manifest);
            packageBuilder.PopulateFiles(string.Empty, files);

            var projDir = _fileSystem.GetDirectory(csprojFile);
            var packagefile = _fileSystem.CombinePaths(projDir, "packages.config");

            var packagePath = _fileSystem.ChangeFileExtension(csprojFile, "nupkg");
            using (var stream = _fileSystem.OpenWrite(packagePath))
            {
                packageBuilder.Save(stream);
            }

            return new ZipPackage(packagePath);
        }
开发者ID:run00,项目名称:TeamCity,代码行数:38,代码来源:PackageFactory.cs

示例5: BuildPackage

        private static void BuildPackage(string nuspecPath, bool signBinaries)
        {
            var repositoryPath = Path.GetDirectoryName(nuspecPath);
            var basePath = Path.Combine(repositoryPath, "files", Path.GetFileNameWithoutExtension(nuspecPath));
            Directory.CreateDirectory(basePath);
            
            var createdFiles = new List<string>();
            bool deleteDir = true;
            using (var fileStream = File.OpenRead(nuspecPath))
            {
                var manifest = Manifest.ReadFrom(fileStream);
                foreach (var file in manifest.Files)
                {
                    string outputPath = Path.Combine(basePath, file.Source);
                    if (File.Exists(outputPath))
                    {
                        deleteDir = false;
                        // A user created file exists. Continue to next file.
                        continue;
                    }
                    
                    createdFiles.Add(outputPath);
                    string outputDir = Path.GetDirectoryName(outputPath);
                    if (!Directory.Exists(outputDir))
                    {
                        Directory.CreateDirectory(outputDir);
                    }

                    if (file.Source.StartsWith(@"lib" + Path.DirectorySeparatorChar) && !file.Source.EndsWith("resources.dll"))
                    {
                        var name = Path.GetFileNameWithoutExtension(file.Source);
                        CreateAssembly(new PackageInfo(manifest.Metadata.Id + ":" + manifest.Metadata.Version),
                                       outputPath: outputPath);
                    }
                    else
                    {
                        File.WriteAllBytes(outputPath, new byte[0]);
                    }
                }

                var packageBuilder = new PackageBuilder();
                packageBuilder.Populate(manifest.Metadata);
                packageBuilder.PopulateFiles(basePath, manifest.Files);
                
                string nupkgDirectory = Path.GetFullPath("packages");
                Directory.CreateDirectory(nupkgDirectory);
                string nupkgPath = Path.Combine(nupkgDirectory, Path.GetFileNameWithoutExtension(nuspecPath)) + ".nupkg";
                using (var nupkgStream = File.Create(nupkgPath))
                {
                    packageBuilder.Save(nupkgStream);
                }
                
                
            }
            try
            {
                if (deleteDir)
                {
                    Directory.Delete(basePath, recursive: true);
                }
                else 
                {
                    // Delete files that we created.
                    createdFiles.ForEach(File.Delete);
                }
            }
            catch { }
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:68,代码来源:Program.cs

示例6: CreateNugget

        private string CreateNugget()
        {
            var csproj = Path.GetFullPath(Path.Combine(ClientDirectory, "LIC.Malone.Client.Desktop.csproj"));
            var bin = Path.GetFullPath(Path.Combine(ClientDirectory, "bin", "Release"));
            var buildDirectoryInfo = Directory.CreateDirectory(BuildDirectory);

            Directory.SetCurrentDirectory(buildDirectoryInfo.FullName);

            // Clean out build directory.
            buildDirectoryInfo
                .GetFiles("*.nupkg")
                .ToList()
                .ForEach(p => p.Delete());

            // Rely on standard nuget process to build the project and create a starting package to copy metadata from.
            StartProcess("nuget.exe", string.Format("pack {0} -Build -Prop Configuration=Release", csproj));

            var nupkg = buildDirectoryInfo.GetFiles("*.nupkg").Single();
            var package = new ZipPackage(nupkg.FullName);

            // Copy all of the metadata *EXCEPT* for dependencies. Kill those.
            var manifest = new ManifestMetadata
            {
                Id = package.Id,
                Version = package.Version.ToString(),
                Authors = string.Join(", ", package.Authors),
                Copyright = package.Copyright,
                DependencySets = null,
                Description = package.Description,
                Title = package.Title,
                IconUrl = package.IconUrl.ToString(),
                ProjectUrl = package.ProjectUrl.ToString(),
                LicenseUrl = package.LicenseUrl.ToString()
            };

            const string target = @"lib\net45";

            // Include dependencies in the package.
            var files = new List<ManifestFile>
            {
                new ManifestFile { Source = "*.dll", Target = target },
                new ManifestFile { Source = "Malone.exe", Target = target },
                new ManifestFile { Source = "Malone.exe.config", Target = target },
            };

            var builder = new PackageBuilder();
            builder.Populate(manifest);
            builder.PopulateFiles(bin, files);

            var nugget = Path.Combine(buildDirectoryInfo.FullName, nupkg.Name);

            using (var stream = File.Open(nugget, FileMode.OpenOrCreate))
            {
                builder.Save(stream);
            }

            return nugget;
        }
开发者ID:Kazetsukai,项目名称:Malone,代码行数:58,代码来源:Releasifyer.cs

示例7: Execute

        public override bool Execute()
        {
            if (Nuspecs == null || Nuspecs.Length == 0)
            {
                Log.LogError("Nuspecs argument must be specified");
                return false;
            }

            if (String.IsNullOrEmpty(OutputDirectory))
            {
                Log.LogError("OuputDirectory argument must be specified");
                return false;
            }

            if (!Directory.Exists(OutputDirectory))
            {
                Directory.CreateDirectory(OutputDirectory);
            }

            foreach (var nuspec in Nuspecs)
            {
                string nuspecPath = nuspec.GetMetadata("FullPath");

                if (!File.Exists(nuspecPath))
                {
                    Log.LogError($"Nuspec {nuspecPath} does not exist");
                    continue;
                }

                try
                {
                    PackageBuilder builder = new PackageBuilder();

                    using (var nuspecFile = File.Open(nuspecPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
                    {
                        Manifest manifest = Manifest.ReadFrom(nuspecFile);
                        builder.Populate(manifest.Metadata);
                        builder.PopulateFiles(Path.GetDirectoryName(nuspecPath), manifest.Files);
                    }

                    string id = builder.Id, version = builder.Version.ToString();

                    if (String.IsNullOrEmpty(id))
                    {
                        Log.LogError($"Nuspec {nuspecPath} does not contain a valid Id");
                        continue;
                    }

                    if (String.IsNullOrEmpty(version))
                    {
                        Log.LogError($"Nuspec {nuspecPath} does not contain a valid version");
                        continue;
                    }

                    string nupkgPath = Path.Combine(OutputDirectory, $"{id}.{version}.nupkg");

                    using (var fileStream = File.Create(nupkgPath))
                    {
                        builder.Save(fileStream);
                    }

                    Log.LogMessage($"Created '{nupkgPath}'");
                }
                catch (Exception e)
                {
                    Log.LogError($"Error when creating nuget package from {nuspecPath}. {e}");
                }
            }

            return !Log.HasLoggedErrors;
        }
开发者ID:jango2015,项目名称:buildtools,代码行数:71,代码来源:NuGetPack.cs

示例8: Pack

        public void Pack(string nuspecPath, Func<string, string> nuspecPropertyProvider, bool packSymbols)
        {
            try
            {
                PackageBuilder builder = new PackageBuilder();

                using (var nuspecFile = File.Open(nuspecPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
                {
                    string baseDirectoryPath = (string.IsNullOrEmpty(BaseDirectory)) ? Path.GetDirectoryName(nuspecPath) : BaseDirectory;
                    Manifest manifest = Manifest.ReadFrom(nuspecFile, nuspecPropertyProvider, false);
                    builder.Populate(manifest.Metadata);
                    builder.PopulateFiles(baseDirectoryPath, manifest.Files);

                    PathResolver.FilterPackageFiles(
                        builder.Files,
                        file => file.Path,
                        packSymbols ? SymbolPackageExcludes : LibPackageExcludes);
                }

                if (packSymbols)
                {
                    // Symbol packages are only valid if they contain both symbols and sources.
                    Dictionary<string, bool> pathHasMatches = LibPackageExcludes.ToDictionary(
                        path => path,
                        path => PathResolver.GetMatches(builder.Files, file => file.Path, new[] { path }).Any());

                    if (!pathHasMatches.Values.Any(i => i))
                    {
                        Log.LogMessage(LogImportance.Low, $"Nuspec {nuspecPath} does not contain symbol or source files. Not creating symbol package.");
                        return;
                    }
                    foreach (var pathPair in pathHasMatches.Where(pathMatchPair => !pathMatchPair.Value))
                    {
                        Log.LogMessage(LogImportance.Low, $"Nuspec {nuspecPath} does not contain any files matching {pathPair.Key}. Not creating symbol package.");
                        return;
                    }
                }

                // Overriding the Version from the Metadata if one gets passed in.
                if (!string.IsNullOrEmpty(PackageVersion))
                {
                    NuGetVersion overrideVersion;
                    if (NuGetVersion.TryParse(PackageVersion, out overrideVersion))
                    {
                        builder.Version = overrideVersion;
                    }
                    else
                    {
                        Log.LogError($"Failed to parse Package Version: '{PackageVersion}' is not a valid version.");
                        return;
                    }
                }

                string id = builder.Id, version = builder.Version.ToString();

                if (String.IsNullOrEmpty(id))
                {
                    Log.LogError($"Nuspec {nuspecPath} does not contain a valid Id");
                    return;
                }

                if (String.IsNullOrEmpty(version))
                {
                    Log.LogError($"Nuspec {nuspecPath} does not contain a valid version");
                    return;
                }

                string nupkgOutputDirectory = OutputDirectory;

                if (packSymbols && !string.IsNullOrEmpty(SymbolPackageOutputDirectory))
                {
                    nupkgOutputDirectory = SymbolPackageOutputDirectory;
                }

                string nupkgExtension = packSymbols ? ".symbols.nupkg" : ".nupkg";
                string nupkgPath = Path.Combine(nupkgOutputDirectory, $"{id}.{version}{nupkgExtension}");

                var directory = Path.GetDirectoryName(nupkgPath);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                using (var fileStream = File.Create(nupkgPath))
                {
                    builder.Save(fileStream);
                }

                Log.LogMessage($"Created '{nupkgPath}'");
            }
            catch (Exception e)
            {
                string packageType = packSymbols ? "symbol" : "lib";
                Log.LogError($"Error when creating nuget {packageType} package from {nuspecPath}. {e}");
            }
        }
开发者ID:ChadNedzlek,项目名称:buildtools,代码行数:96,代码来源:NuGetPack.cs

示例9: Execute

        public void Execute(string[] commandLineArguments)
        {
            options.Parse(commandLineArguments);

            if (string.IsNullOrWhiteSpace(id))
                throw new CommandException("An ID is required");

            if (includes.All(string.IsNullOrWhiteSpace))
                includes.Add("**");

            if (string.IsNullOrWhiteSpace(basePath))
                basePath = Path.GetFullPath(Environment.CurrentDirectory);

            if (string.IsNullOrWhiteSpace(outFolder))
                outFolder = Path.GetFullPath(Environment.CurrentDirectory);

            if (version == null)
            {
                var now = DateTime.Now;
                version = new SemanticVersion(now.Year, now.Month, now.Day, now.Hour*10000 + now.Minute*100 + now.Second);
            }
            else
            {
                // Make sure SpecialVersion has 20 characters maximum (Limit imposed by NuGet)
                // https://nuget.codeplex.com/workitem/3426

                const int nugetSpecialVersionMaxLength = 20;
                if (!string.IsNullOrWhiteSpace(version.SpecialVersion) && version.SpecialVersion.Length > nugetSpecialVersionMaxLength)
                {
                    log.WarnFormat("SpecialVersion '{0}' will be truncated to {1} characters (NuGet limit)",
                        version.SpecialVersion, nugetSpecialVersionMaxLength);

                    var specialVersion = version.SpecialVersion;
                    specialVersion = specialVersion.Substring(0, Math.Min(nugetSpecialVersionMaxLength, specialVersion.Length));

                    version = new SemanticVersion(version.Version, specialVersion);
                }
            }

            if (authors.All(string.IsNullOrWhiteSpace))
                authors.Add(Environment.UserName + "@" + Environment.UserDomainName);

            if (string.IsNullOrWhiteSpace(description))
                description = "A deployment package created from files on disk.";

            string allReleaseNotes = null;
            if (!string.IsNullOrWhiteSpace(releaseNotesFile))
            {
                if (!File.Exists(releaseNotesFile))
                    log.WarnFormat("The release notes file '{0}' could not be found", releaseNotesFile);
                else
                    allReleaseNotes = fileSystem.ReadFile(releaseNotesFile);
            }

            if (!string.IsNullOrWhiteSpace(releaseNotes))
            {
                if (allReleaseNotes != null)
                    allReleaseNotes += Environment.NewLine + releaseNotes;
                else
                    allReleaseNotes = releaseNotes;
            }

            var metadata = new ManifestMetadata
            {
                Id = id,
                Authors = string.Join(", ", authors),
                Description = description,
                Version = version.ToString(),
            };

            if (!string.IsNullOrWhiteSpace(allReleaseNotes))
                metadata.ReleaseNotes = allReleaseNotes;

            if (!string.IsNullOrWhiteSpace(title))
                metadata.Title = title;

            log.InfoFormat("Packing {0} version {1}...", id, version);

            var package = new PackageBuilder();

            package.PopulateFiles(basePath, includes.Select(i => new ManifestFile {Source = i}));
            package.Populate(metadata);

            var filename = metadata.Id + "." + metadata.Version + ".nupkg";
            var output = Path.Combine(outFolder, filename);

            if (fileSystem.FileExists(output) && !overwrite)
                throw new CommandException("The package file already exists and --overwrite was not specified");

            log.InfoFormat("Saving {0} to {1}...", filename, outFolder);

            fileSystem.EnsureDirectoryExists(outFolder);

            using (var outStream = fileSystem.OpenFile(output, FileMode.Create))
                package.Save(outStream);

            log.InfoFormat("Done.");
        }
开发者ID:cloudrifles,项目名称:Octopus-Tools,代码行数:98,代码来源:PackCommand.cs

示例10: Main

        public static void Main(string[] args)
        {
            string contentPath;
            string destinationPath;
            string packageId;
            int numberOfPackages;
            int randomFileSize;

            if (args.Length == 5)
            {
                contentPath = args[0];
                destinationPath = args[1];
                packageId = args[2];
                numberOfPackages = Int32.Parse(args[3]);
                randomFileSize = Int32.Parse(args[4]);
            }
            else
            {
                Console.WriteLine("Package content path:");
                contentPath = Console.ReadLine();
                Console.WriteLine("Package destination path:");
                destinationPath = Console.ReadLine();
                Console.WriteLine("Package id:");
                packageId = Console.ReadLine();
                Console.WriteLine("Number of packages:");
                numberOfPackages = Int32.Parse(Console.ReadLine());
                Console.WriteLine("Random file size (kb):");
                randomFileSize = Int32.Parse(Console.ReadLine());
            }

            var includes = new List<string>
            {
                "**"
            };

            for (var i = 0; i < numberOfPackages; i++)
            {
                var version = new SemanticVersion(1, i, 0, 0);
                var metadata = new ManifestMetadata
                {
                    Id = packageId,
                    Version = version.ToString(),
                    Authors = "Testing",
                    Description = "A test package"
                };

                var randomFile = Path.Combine(contentPath, "random.txt");
                GenerateRandomFile(randomFile, randomFileSize);

                var package = new PackageBuilder();

                package.PopulateFiles(contentPath, includes.Select(include =>
                    new ManifestFile { Source = include })
                );
                package.Populate(metadata);

                var filename = metadata.Id + "." + metadata.Version + ".nupkg";
                var output = Path.Combine(destinationPath, filename);

                using (var outStream = File.Open(output, FileMode.Create))
                    package.Save(outStream);
            }
        }
开发者ID:tothegills,项目名称:NuGetPackageGenerator,代码行数:63,代码来源:Program.cs

示例11: BuildPackage

    private void BuildPackage(Manifest manifest)
    {
      var builder = new PackageBuilder();
      builder.Populate(manifest.Metadata);
      builder.PopulateFiles(_outputPath, manifest.Files);
      var file = Path.Combine(_outputPath, string.Format("{0}.{1}.nupkg", builder.Id, builder.Version));
      var localRepo = new LocalPackageRepository(_outputPath, NuspecDefinition.PackageSource);

      if (File.Exists(file))
      {
        File.Delete(file);
      }

      using (var buildFile = File.Open(file, FileMode.OpenOrCreate))
      {
        builder.Save(buildFile);
        buildFile.Flush();
        buildFile.Close();
      }
      var package = localRepo.GetPackage(builder.Id, builder.Version);

      if (NuspecDefinition.PublishPackage)
      {
        localRepo.PushPackage(package);
      }
    }
开发者ID:talisker77,项目名称:Package.Util,代码行数:26,代码来源:Creator.cs

示例12: Do

        private static void Do(LocalPackageRepository inputRepository, PackageManager inputManager, IPackage package, string cacheDirectory, IEnumerable<string> references, string outputDirectory)
        {
            Console.WriteLine("--- Building {0} ---", package.GetFullName());
            var solution = new ProjectCollection();
            var logger = new ConsoleLogger();
            logger.Verbosity = LoggerVerbosity.Minimal;

            inputManager.InstallPackage(package, false, false);
            var packageDirectory = Path.Combine(cacheDirectory, package.Id);
            var moduleDirectory = Directory.GetDirectories(Path.Combine(packageDirectory, "Content", "Modules"))[0];
            var moduleName = Path.GetFileName(moduleDirectory);
            var project = solution.LoadProject(Path.Combine(moduleDirectory, moduleName + ".csproj"));

            var candidateDirectories = references
                   .Select(r => Path.Combine(cacheDirectory, r))
                   .Concat(Directory.EnumerateDirectories(cacheDirectory).Where(d => !Path.GetFileName(d).StartsWith("Orchard.")))
                   .Join(new[] { "net40-full", "net40", "net35", "net20", "net", "" }, l => true, r => true, (l, r) => Path.Combine(l, "lib", r))
                   .Where(Directory.Exists)
                   .ToList();

            foreach (var item in GetReferences(project).ToList())
            {
                var referenceName = GetReferenceName(item);
                var referenceDirectory = candidateDirectories.FirstOrDefault(d => File.Exists(Path.Combine(d, referenceName + ".dll")));

                if (referenceDirectory != null)
                {
                    Console.WriteLine("Replacing reference {0} with {1}", referenceName, referenceDirectory);
                    ReplaceReference(project, item, referenceName, referenceDirectory);
                }
            }

            var dependencies = new List<ManifestDependency>();

            foreach (var item in GetModuleReferences(project).ToList())
            {
                var referencedModuleName = item.GetMetadataValue("Name");
                var referencedPackageId = "Orchard.Module." + item.GetMetadataValue("Name");
                var referencedPackage = inputRepository.FindPackage(referencedPackageId);

                Console.WriteLine("Depends on {0}", referencedModuleName);
                dependencies.Add(new ManifestDependency { Id = referencedPackage.Id, Version = "[" + referencedPackage.Version + "]" });

                Do(inputRepository, inputManager, referencedPackage, cacheDirectory, references, outputDirectory);
                ReplaceReference(project, item, referencedModuleName, Path.Combine(cacheDirectory, referencedPackageId, "Content", "Modules", referencedModuleName, "bin"));
            }

            if (!File.Exists(Path.Combine(moduleDirectory, "bin", moduleName + ".dll")))
                if (!project.Build(logger))
                    throw new Exception("Failed to build");

            var rules = new[]
                {
                    @"bin\" + moduleName + ".dll",
                    @"Module.txt",
                    @"Placement.info",
                    @"Web.config",
                    @"Content\**",
                    @"Scripts\**",
                    @"Recipes\**",
                    @"Styles\**",
                    @"Views\**"
                };

            var manifest = Manifest.Create(package);
            manifest.Metadata.DependencySets = new List<ManifestDependencySet> { new ManifestDependencySet { Dependencies = dependencies } };
            manifest.Files = rules.Select(r => new ManifestFile { Source = @"Content\Modules\" + moduleName + @"\**\" + r, Target = @"Content\Modules\" + moduleName }).ToList();

            var builder = new PackageBuilder();
            builder.Populate(manifest.Metadata);
            builder.PopulateFiles(packageDirectory, manifest.Files);

            Directory.CreateDirectory(outputDirectory);
            var outputPackgeFileName = Path.Combine(outputDirectory, manifest.Metadata.Id + "." + manifest.Metadata.Version + ".nupkg");
            using (var outputPackageFile = File.Create(outputPackgeFileName))
                builder.Save(outputPackageFile);
        }
开发者ID:SymbolSource,项目名称:Orchard,代码行数:77,代码来源:Program.cs


注:本文中的NuGet.PackageBuilder.PopulateFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。