Beispiel #1
0
        private void writeZipFile(CreateBottleInput input, PackageManifest manifest, AssemblyFiles assemblies)
        {
            var zipFileName = input.GetZipFileName(manifest);

            if (_fileSystem.FileExists(zipFileName))
            {
                LogWriter.Current.Highlight("    Deleting existing file at " + zipFileName);
                _fileSystem.DeleteFile(zipFileName);
            }

            _zipFileService.CreateZipFile(zipFileName, zipFile =>
            {
                assemblies.Files.Each(file =>
                {
                    zipFile.AddFile(file, "bin");
                });

                if (input.PdbFlag)
                {
                    assemblies.PdbFiles.Each(file =>
                    {
                        zipFile.AddFile(file, "bin");
                    });
                }

                WriteVersion(zipFile);

                zipFile.AddFile(FileSystem.Combine(input.PackageFolder, PackageManifest.FILE), "");

                // TODO -- there's an opportunity to generalize this
                AddDataFiles(input, zipFile, manifest);
                AddContentFiles(input, zipFile, manifest);
                AddConfigFiles(input, zipFile, manifest);
            });
        }
Beispiel #2
0
 public void AddDataFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
 {
     zipFile.AddFiles(new ZipFolderRequest()
                      {
                          FileSet = FileSet.Deep("*"),
                          ZipDirectory = BottleFiles.DataFolder,
                          RootDirectory = Path.Combine(input.PackageFolder, BottleFiles.DataFolder)
                      });
 }
Beispiel #3
0
 public void AddConfigFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
 {
     ConsoleWriter.Write("      Adding Config folder for " + BottleFiles.ConfigFiles);
     zipFile.AddFiles(new ZipFolderRequest(){
         FileSet = BottleFiles.ConfigFiles,
         RootDirectory = input.PackageFolder,
         ZipDirectory = BottleFiles.ConfigFolder
     });
 }
Beispiel #4
0
 public void AddDataFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
 {
     zipFile.AddFiles(new ZipFolderRequest()
     {
         FileSet       = FileSet.Deep("*"),
         ZipDirectory  = BottleFiles.DataFolder,
         RootDirectory = Path.Combine(input.PackageFolder, BottleFiles.DataFolder)
     });
 }
Beispiel #5
0
 public void AddConfigFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
 {
     ConsoleWriter.Write("      Adding Config folder for " + BottleFiles.ConfigFiles);
     zipFile.AddFiles(new ZipFolderRequest()
     {
         FileSet       = FileSet.Deep("*"),
         ZipDirectory  = BottleFiles.ConfigFolder,
         RootDirectory = Path.Combine(input.PackageFolder, BottleFiles.ConfigFolder)
     });
 }
        public void WriteAssembliesNotFound(AssemblyFiles theAssemblyFiles, PackageManifest manifest, CreateBottleInput input, string binFolder)
        {
            ConsoleWriter.Write("Did not locate all designated assemblies at '{0}'", binFolder);
            ConsoleWriter.Write("Looking for these assemblies in the package manifest file:");
            manifest.Assemblies.Each(name => ConsoleWriter.Write("  " + name));
            ConsoleWriter.Write("But only found:");
            if(!theAssemblyFiles.Files.Any()) ConsoleWriter.Write("  Found no files");
            theAssemblyFiles.Files.Each(file => ConsoleWriter.Write("  " + file));

            ConsoleWriter.Write("Missing");
            theAssemblyFiles.MissingAssemblies.Each(file => ConsoleWriter.Write("  " + file));
        
            throw new ApplicationException("Invalid package manifest or missing files");
        }
Beispiel #7
0
        public bool CreatePackage(CreateBottleInput input, PackageManifest manifest)
        {
            var binFolder = _fileSystem.FindBinaryDirectory(input.PackageFolder, input.TargetFlag);

            var assemblies = _assemblyFinder.FindAssemblies(binFolder, manifest.Assemblies);
            if (assemblies.Success)
            {
                writeZipFile(input, manifest, assemblies);
                return true;
            }

            _logger.WriteAssembliesNotFound(assemblies, manifest, input, binFolder);
            return false;
        }
Beispiel #8
0
        public void CreatePackage(CreateBottleInput input, PackageManifest manifest)
        {
            var binFolder = _fileSystem.FindBinaryDirectory(input.PackageFolder, input.TargetFlag);

            var assemblies = _assemblyFinder.FindAssemblies(binFolder, manifest.Assemblies);

            if (assemblies.Success)
            {
                writeZipFile(input, manifest, assemblies);
                return;
            }

            _logger.WriteAssembliesNotFound(assemblies, manifest, input, binFolder);
        }
        public void AddConfigFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
        {
            if (manifest.ConfigFileSet == null)
            {
                ConsoleWriter.Write("      No config files");
                return;
            }

            ConsoleWriter.Write("      Adding Config folder for " + manifest.ConfigFileSet);
            zipFile.AddFiles(new ZipFolderRequest(){
                FileSet = manifest.ConfigFileSet,
                RootDirectory = input.PackageFolder,
                ZipDirectory = BottleFiles.ConfigFolder
            });
        }
        public void AddDataFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
        {
            if (manifest.DataFileSet == null)
            {
                ConsoleWriter.Write("      No data files");
                return;
            }

            ConsoleWriter.Write("      Adding Data folder for " + manifest.DataFileSet);
            zipFile.AddFiles(new ZipFolderRequest()
                             {
                                 FileSet = manifest.DataFileSet,
                                 ZipDirectory = BottleFiles.DataFolder,
                                 RootDirectory = Path.Combine(input.PackageFolder, BottleFiles.DataFolder)
                             });
        }
Beispiel #11
0
        public void AddDataFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
        {
            if (manifest.DataFileSet == null)
            {
                ConsoleWriter.Write("      No data files");
                return;
            }

            ConsoleWriter.Write("      Adding Data folder for " + manifest.DataFileSet);
            zipFile.AddFiles(new ZipFolderRequest()
            {
                FileSet       = manifest.DataFileSet,
                ZipDirectory  = BottleFiles.DataFolder,
                RootDirectory = Path.Combine(input.PackageFolder, BottleFiles.DataFolder)
            });
        }
Beispiel #12
0
        public void AddConfigFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
        {
            if (manifest.ConfigFileSet == null)
            {
                ConsoleWriter.Write("      No config files");
                return;
            }


            ConsoleWriter.Write("      Adding Config folder for " + manifest.ConfigFileSet);
            zipFile.AddFiles(new ZipFolderRequest()
            {
                FileSet       = manifest.ConfigFileSet,
                RootDirectory = input.PackageFolder,
                ZipDirectory  = BottleFiles.ConfigFolder
            });
        }
        public void AddContentFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
        {
            if (manifest.ContentFileSet == null)
            {
                ConsoleWriter.Write("      No WebContent files");
                return;
            }

            ConsoleWriter.Write("      Adding WebContent folder for " + manifest.ContentFileSet);
            manifest.ContentFileSet.AppendExclude(FileSystem.Combine("bin","*.*"));

            zipFile.AddFiles(new ZipFolderRequest()
                             {
                                 FileSet = manifest.ContentFileSet,
                                 ZipDirectory = BottleFiles.WebContentFolder,
                                 RootDirectory = input.PackageFolder
                             });
        }
Beispiel #14
0
        public void AddContentFiles(CreateBottleInput input, IZipFile zipFile, PackageManifest manifest)
        {
            if (manifest.ContentFileSet == null)
            {
                ConsoleWriter.Write("      No WebContent files");
                return;
            }

            ConsoleWriter.Write("      Adding WebContent folder for " + manifest.ContentFileSet);
            manifest.ContentFileSet.AppendExclude(FileSystem.Combine("bin", "*.*"));

            zipFile.AddFiles(new ZipFolderRequest()
            {
                FileSet       = manifest.ContentFileSet,
                ZipDirectory  = BottleFiles.WebContentFolder,
                RootDirectory = input.PackageFolder
            });
        }
        public void WriteAssembliesNotFound(AssemblyFiles theAssemblyFiles, PackageManifest manifest, CreateBottleInput input, string binFolder)
        {
            var log = _log.LogFor(manifest);

            var sb = new StringBuilder();
            sb.AppendFormat("Did not locate all designated assemblies at '{0}'", binFolder.ToFullPath());
            sb.AppendLine();

            sb.AppendLine("Looking for these assemblies in the package manifest file:");
            manifest.Assemblies.Each(name => sb.AppendLine("  " + name));

            sb.AppendLine("But only found:");
            if(!theAssemblyFiles.Files.Any()) sb.AppendLine("  Found no files");
            theAssemblyFiles.Files.Each(file => sb.AppendLine("  " + file));

            sb.AppendLine("Missing");
            theAssemblyFiles.MissingAssemblies.Each(file => sb.AppendLine("  " + file));

            log.MarkFailure(sb.ToString());
        }
        private void writeZipFile(CreateBottleInput input, PackageManifest manifest, AssemblyFiles assemblies)
        {
            var zipFileName = input.GetZipFileName(manifest);

            if (_fileSystem.FileExists(zipFileName))
            {
                LogWriter.Current.Highlight("    Deleting existing file at " + zipFileName);
                _fileSystem.DeleteFile(zipFileName);
            }

            _zipFileService.CreateZipFile(zipFileName, zipFile =>
            {
                assemblies.Files.Each(file =>
                {
                    zipFile.AddFile(file, "bin");
                });

                if (input.PdbFlag)
                {
                    assemblies.PdbFiles.Each(file =>
                    {
                        zipFile.AddFile(file, "bin");
                    });
                }

                WriteVersion(zipFile);

                zipFile.AddFile(FileSystem.Combine(input.PackageFolder, PackageManifest.FILE), "");

                // TODO -- there's an opportunity to generalize this
                AddDataFiles(input, zipFile, manifest);
                AddContentFiles(input, zipFile, manifest);
                AddConfigFiles(input, zipFile, manifest);
            });
        }