// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
namespace WixToolset.BuildTasks
{
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
#if false
///
/// An MSBuild task to run the WiX transform generator.
///
public sealed class Insignia : WixToolTask
{
private const string InsigniaToolName = "insignia.exe";
///
/// Gets or sets the path to the database to inscribe.
///
public ITaskItem DatabaseFile { get; set; }
///
/// Gets or sets the path to the bundle to inscribe.
///
public ITaskItem BundleFile { get; set; }
///
/// Gets or sets the path to the original bundle that contains the attached container.
///
public ITaskItem OriginalBundleFile { get; set; }
///
/// Gets or sets the path to output the inscribed result.
///
[Required]
public ITaskItem OutputFile { get; set; }
///
/// Gets or sets the output. Only set if insignia does work.
///
[Output]
public ITaskItem Output { get; set; }
///
/// Get the name of the executable.
///
/// The ToolName is used with the ToolPath to get the location of Insignia.exe.
/// The name of the executable.
protected override string ToolName
{
get { return InsigniaToolName; }
}
///
/// Get the path to the executable.
///
/// GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).
/// The full path to the executable or simply Insignia.exe if it's expected to be in the system path.
protected override string GenerateFullPathToTool()
{
// If there's not a ToolPath specified, it has to be in the system path.
if (String.IsNullOrEmpty(this.ToolPath))
{
return InsigniaToolName;
}
return Path.Combine(Path.GetFullPath(this.ToolPath), InsigniaToolName);
}
///
/// Builds a command line from options in this task.
///
protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
{
base.BuildCommandLine(commandLineBuilder);
commandLineBuilder.AppendSwitchIfNotNull("-im ", this.DatabaseFile);
if (null != this.OriginalBundleFile)
{
commandLineBuilder.AppendSwitchIfNotNull("-ab ", this.BundleFile);
commandLineBuilder.AppendFileNameIfNotNull(this.OriginalBundleFile);
}
else
{
commandLineBuilder.AppendSwitchIfNotNull("-ib ", this.BundleFile);
}
commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
}
///
/// Executes a tool in-process by loading the tool assembly and invoking its entrypoint.
///
/// Path to the tool to be executed; must be a managed executable.
/// Commands to be written to a response file.
/// Commands to be passed directly on the command-line.
/// The tool exit code.
protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
{
int returnCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
if (0 == returnCode) // successfully did work.
{
this.Output = this.OutputFile;
}
else if (-1 == returnCode) // no work done.
{
returnCode = 0;
}
return returnCode;
}
}
#endif
}