/// /// Copyright © 2003-2008 JetBrains s.r.o. /// You may distribute under the terms of the GNU General Public License, as published by the Free Software Foundation, version 2 (see License.txt in the repository root folder). /// using JetBrains.Build.Common.Infra; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace JetBrains.Build.Common.Tasks { /// /// Compiles the MS-Help files into the Document Explorer format. /// public class MsHelp2 : ToolTaskBase { #region Attributes /// /// Gets or sets the project (Collection, HxC) file. /// [Required] public ITaskItem HelpCollectionFile { get { return (ITaskItem)Bag[AttributeName.HelpCollectionFile]; } set { Bag[AttributeName.HelpCollectionFile] = value; } } /// /// Gets or sets the name of the output (generated, HxS) file. /// [Required] public ITaskItem OutputFile { get { return (ITaskItem)Bag[AttributeName.OutputFile]; } set { Bag[AttributeName.OutputFile] = value; } } /// /// Gets or sets the help project root. /// [Required] public ITaskItem ProjectDir { get { return (ITaskItem)Bag[AttributeName.ProjectDir]; } set { Bag[AttributeName.ProjectDir] = value; } } #endregion #region Overrides /// ///Creates a temporoary response (.rsp) file and runs the executable file. /// /// /// ///The returned exit code of the executable file. If the task logged errors, but the executable returned an exit code of 0, this method returns -1. /// /// ///The command line arguments to pass directly to the executable file. ///The command line arguments to place in the .rsp file. ///The path to the executable file. protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { int nExitCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); Log.LogMessage(MessageImportance.Normal, "The “{0}” tool has exited with code {1}.", ToolName, nExitCode); return 0; // Suppress fake error codes } /// ///Returns a string value containing the command line arguments to pass directly to the executable file. /// /// /// ///A string value containing the command line arguments to pass directly to the executable file. /// /// protected override string GenerateCommandLineCommands() { var cmd = new CommandLineBuilder(); cmd.AppendSwitch("-p"); cmd.AppendFileNameIfNotNull(TaskHelper.GetValue(Bag, AttributeName.HelpCollectionFile)); cmd.AppendSwitch("-r"); cmd.AppendFileNameIfNotNull(TaskHelper.GetValue(Bag, AttributeName.ProjectDir)); cmd.AppendSwitch("-o"); cmd.AppendFileNameIfNotNull(TaskHelper.GetValue(Bag, AttributeName.OutputFile)); return cmd.ToString(); } /// ///Gets the name of the executable file to run. /// /// /// ///The name of the executable file to run. /// /// protected override string ToolName { get { return "HxComp.exe"; } } #endregion } }