public IPackageDef Process(IPackageDef packageDef) { StandardPackageDef zippedPackageDef = new StandardPackageDef(); List <string> filesToZip = new List <string>(); foreach (IFilesSource childSource in packageDef.ListChildSources()) { if (sourcesToZip.Contains(childSource.Id)) { foreach (PackagedFileInfo file in childSource.ListFiles()) { if (false == LoggingHelper.LogIfFilteredOut(file.FullPath.ToString(), filter, logger)) { continue; } logger.Log("Adding file '{0}' to zip package", file.FullPath); filesToZip.Add(file.FullPath.ToString()); } } } zipper.ZipFiles(zipFileName, baseDir, compressionLevel, filesToZip); SingleFileSource singleFileSource = new SingleFileSource("zip", zipFileName); zippedPackageDef.AddFilesSource(singleFileSource); return(zippedPackageDef); }
public IPackageDef Process(IPackageDef packageDef) { StandardPackageDef zippedPackageDef = new StandardPackageDef(); List <FileFullPath> filesToZip = new List <FileFullPath>(); foreach (IFilesSource childSource in packageDef.ListChildSources()) { if (_sourcesToZip.Contains(childSource.Id)) { foreach (PackagedFileInfo file in childSource.ListFiles()) { if (!LoggingHelper.LogIfFilteredOut(file.FileFullPath.ToString(), _filter, _taskContext, _logFiles)) { continue; } if (_logFiles) { _taskContext.LogInfo($"Adding file '{file.FileFullPath}' to zip package"); } filesToZip.Add(file.FileFullPath); } } } _zipper.ZipFiles(_zipFileName, _baseDir, filesToZip, _optimizeFiles); SingleFileSource singleFileSource = new SingleFileSource("zip", _zipFileName); zippedPackageDef.AddFilesSource(singleFileSource); return(zippedPackageDef); }
public void TestZipProcessor() { IZipper zipper = MockRepository.GenerateMock <IZipper>(); ZipProcessor zipProcessor = new ZipProcessor( logger, zipper, "some.zip", "test", null, "console", "win.service"); IPackageDef zippedPackageDef = zipProcessor.Process(package); Assert.AreEqual(1, zippedPackageDef.ListChildSources().Count); }