示例#1
0
        protected override bool OnExecute(BuildContext context)
        {
            _contentTypes = new BuildProperties();

            _contentTypes[".js"]  = "text/javascript; charset=utf-8";
            _contentTypes[".xap"] = "application/x-silverlight-app";
            _contentTypes[".htm"] = "text/html; charset=utf-8";
            _contentTypes[".gif"] = "image/gif";
            _contentTypes[".png"] = "image/png";
            _contentTypes[".jpg"] = "image/jpeg";

            if (String.IsNullOrEmpty(_helpName) ||
                String.IsNullOrEmpty(_helpFolder) ||
                String.IsNullOrEmpty(_helpDirectory))
            {
                throw new BuildException("The required property values are set.");
            }
            _helpSource = Path.Combine(this.WorkingDirectory, _helpFolder);
            if (!Directory.Exists(_helpSource))
            {
                throw new BuildException("The help file sources directory does not exist.");
            }

            _helpOutputDir = Path.Combine(_helpDirectory, _helpFolder);
            if (!Directory.Exists(_helpDirectory))
            {
                Directory.CreateDirectory(_helpDirectory);
            }
            if (!Directory.Exists(_helpOutputDir))
            {
                Directory.CreateDirectory(_helpOutputDir);
            }

            this.OptimizeStyles(context);

            this.CreateMsha(context);
            this.CreateMshc(context);

            context.AddOutput(BuildFormatType.HtmlHelp3,
                              Path.Combine(_helpOutputDir, _helpName + ".mshc"));

            return(true);
        }
示例#2
0
        protected override bool OnExecute(BuildContext context)
        {
            BuildLogger logger = context.Logger;

            if (logger != null)
            {
                _verbosity = logger.Verbosity;
            }

            string appName = Path.GetFileName(this.Application);

            if (String.Equals(appName, "hhc.exe",
                              StringComparison.OrdinalIgnoreCase))
            {
                // hhc.exe is different, returns 0 if an error occurs
                this.ExpectedExitCode = 1;
            }
            else
            {
                // Unlike the hhc.exe tool,  SbAppLocale.exe will return 0 on success.
                this.ExpectedExitCode = 0;
            }

            bool buildResult = base.OnExecute(context);

            // If the build is successful, we will need to handle the output...
            if (!buildResult || String.IsNullOrEmpty(_helpDirectory) ||
                String.IsNullOrEmpty(_helpFolder))
            {
                return(buildResult);
            }

            if (!Directory.Exists(_helpDirectory))
            {
                Directory.CreateDirectory(_helpDirectory);
            }
            string helpOutput = Path.Combine(_helpDirectory, _helpFolder);

            string workingDir = this.WorkingDirectory;

            if (_keepSources)
            {
                // If requested to keep the build sources, just move it to
                // the output directory...
                string compiledDir = Path.Combine(workingDir, _helpFolder);
                if (!Directory.Exists(compiledDir))
                {
                    return(buildResult);
                }
                if (Directory.Exists(helpOutput))
                {
                    DirectoryUtils.DeleteDirectory(helpOutput, true);
                }
                Directory.Move(compiledDir, helpOutput);

                string destHelpPath = Path.Combine(helpOutput, _helpName + ".chm");
                context.AddOutput(BuildFormatType.HtmlHelp1, destHelpPath);
            }
            else
            {
                if (!Directory.Exists(helpOutput))
                {
                    Directory.CreateDirectory(helpOutput);
                }
                string sourceHelpPath = Path.Combine(workingDir,
                                                     String.Format(@"{0}\{1}.chm", _helpFolder, _helpName));
                string destHelpPath = Path.Combine(helpOutput, _helpName + ".chm");
                if (File.Exists(sourceHelpPath))
                {
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);

                    context.AddOutput(BuildFormatType.HtmlHelp1, destHelpPath);
                }
                sourceHelpPath = Path.ChangeExtension(sourceHelpPath, ".log");
                if (File.Exists(sourceHelpPath))
                {
                    destHelpPath = Path.ChangeExtension(destHelpPath, ".log");
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);
                }
            }

            return(buildResult);
        }
示例#3
0
        protected override bool OnExecute(BuildContext context)
        {
            bool processResult = false;

            if (String.IsNullOrEmpty(this.Application) &&
                String.IsNullOrEmpty(this.Arguments))
            {
                if (String.IsNullOrEmpty(_projectFile) ||
                    File.Exists(_projectFile) == false)
                {
                    return(processResult);
                }
            }

            BuildLogger logger = context.Logger;

            try
            {
                if (String.IsNullOrEmpty(_projectFile) ||
                    File.Exists(_projectFile) == false)
                {
                    processResult = this.Run(logger);
                }
                else
                {
                    HxComp hxsCompiler = new HxComp();
                    hxsCompiler.Initialize();

                    HxCompError compilerError = new HxCompError(logger, this.Verbosity);

                    compilerError.Attach(hxsCompiler);

                    hxsCompiler.Compile(_projectFile, Path.GetDirectoryName(_projectFile),
                                        null, 0);

                    compilerError.Detach(hxsCompiler);
                    hxsCompiler = null;

                    processResult = compilerError.IsSuccess;
                }

                if (!processResult)
                {
                    return(processResult);
                }
            }
            catch (ArgumentException)
            {
                // If the COM server compiler fails, run the command line version...
                processResult = this.Run(logger);

                if (!processResult)
                {
                    return(processResult);
                }
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.WriteLine(ex, BuildLoggerLevel.Error);
                }

                return(false);
            }

            // If the help is successfully compiled, then...
            // 1. Copy the compiled help files to the output folder...
            string workingDir = this.WorkingDirectory;

            if (!Directory.Exists(_helpDirectory))
            {
                Directory.CreateDirectory(_helpDirectory);
            }
            // If we need to keep the help sources, then just copy everything to
            // the output folder...
            string helpOutput = Path.Combine(_helpDirectory, _helpFolder);

            if (_keepSources)
            {
                string compiledDir = Path.Combine(workingDir, _helpFolder);
                if (!Directory.Exists(compiledDir))
                {
                    return(processResult);
                }
                if (Directory.Exists(helpOutput))
                {
                    DirectoryUtils.DeleteDirectory(helpOutput, true);
                }
                Directory.Move(compiledDir, helpOutput);

                string destHelpPath = Path.Combine(helpOutput, _helpName + ".HxS");
                context.AddOutput(BuildFormatType.HtmlHelp2, destHelpPath);
            }
            else  //...otherwise, just copy the essentials...
            {
                if (!Directory.Exists(helpOutput))
                {
                    Directory.CreateDirectory(helpOutput);
                }
                string sourceHelpPath = Path.Combine(workingDir,
                                                     String.Format(@"{0}\{1}.HxS", _helpFolder, _helpName));
                string destHelpPath = Path.Combine(helpOutput, _helpName + ".HxS");
                if (File.Exists(sourceHelpPath))
                {
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);
                    context.AddOutput(BuildFormatType.HtmlHelp2, destHelpPath);
                }
                // Copy the log file, if available...
                sourceHelpPath = Path.ChangeExtension(sourceHelpPath, ".log");
                if (File.Exists(sourceHelpPath))
                {
                    destHelpPath = Path.ChangeExtension(destHelpPath, ".log");
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);
                }
                // Copy the separated index file, if available...
                sourceHelpPath = Path.ChangeExtension(sourceHelpPath, ".HxI");
                if (File.Exists(sourceHelpPath))
                {
                    destHelpPath = Path.ChangeExtension(destHelpPath, ".HxI");
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);
                }
            }

            // 2. Create the help collection files for registration...
            processResult = CreateCollection(context);

            return(processResult);
        }