Пример #1
0
        public override bool Execute()
        {
            Log.LogMessage(MessageImportance.Normal, "Creating ISO file: '{0}'", FileName.ItemSpec);

            try
            {
                CDBuilder builder = new CDBuilder();
                builder.UseJoliet = UseJoliet;

                if (!string.IsNullOrEmpty(VolumeLabel))
                {
                    builder.VolumeIdentifier = VolumeLabel;
                }

                Stream bootImageStream = null;
                if (BootImage != null)
                {
                    bootImageStream = new FileStream(BootImage.GetMetadata("FullPath"), FileMode.Open, FileAccess.Read);
                    builder.SetBootImage(bootImageStream, BootDeviceEmulation.NoEmulation, 0);
                    builder.UpdateIsolinuxBootTable = UpdateIsolinuxBootTable;
                }

                foreach (var sourceFile in SourceFiles)
                {
                    builder.AddFile(GetDestinationPath(sourceFile), sourceFile.GetMetadata("FullPath"));
                }

                try
                {
                    builder.Build(FileName.ItemSpec);
                }
                finally
                {
                    if (bootImageStream != null)
                    {
                        bootImageStream.Dispose();
                    }
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e, true, true, null);
                return(false);
            }

            return(!Log.HasLoggedErrors);
        }