/// /// 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 { /// /// Signs the files with Microsoft Authenticode. /// Note: this file calls the SignTool.exe manually instead of using the MSBuild utilities. /// public class Sign : ToolTaskBase { #region Attributes /// /// The input files that will be signed by the task. /// [Required] public ITaskItem[] InputFiles { get { return BagGetTry(AttributeName.InputFiles); } set { BagSet(AttributeName.InputFiles, value); } } /// /// The file that contains the private keys to use for signing. /// [Required] public ITaskItem KeyFile { get { return BagGetTry(AttributeName.KeyFile); } set { BagSet(AttributeName.KeyFile, value); } } /// /// Specifies an optional server to timestamp the files being signed. /// public string TimestampingServer { get { return BagGetTry(AttributeName.TimestampingServer); } set { BagSet(AttributeName.TimestampingServer, value); } } /// /// Whether the tool output should be verbose. /// public bool Verbose { get { return BagGetTry(AttributeName.Verbose); } set { BagSet(AttributeName.Verbose, value); } } #endregion #region Overrides /// ///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(); // signtool mode cmd.AppendSwitch("sign"); // Verbose output? if(BagGet(AttributeName.Verbose, false)) cmd.AppendSwitch("/v"); // Key file cmd.AppendSwitch("/f"); cmd.AppendFileNameIfNotNull(BagGet(AttributeName.KeyFile)); // Timestamp if(BagContains(AttributeName.TimestampingServer)) { cmd.AppendSwitch("/t"); cmd.AppendSwitch(BagGet(AttributeName.TimestampingServer)); } // The files to process foreach(ITaskItem item in BagGet(AttributeName.InputFiles)) cmd.AppendFileNameIfNotNull(item); 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 "signtool.exe"; } } #endregion } }