Light.cs :  » Installers-Generators » WiX » Microsoft » Tools » WindowsInstallerXml » Build » Tasks » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Installers Generators » WiX 
WiX » Microsoft » Tools » WindowsInstallerXml » Build » Tasks » Light.cs
//-------------------------------------------------------------------------------------------------
// <copyright file="Light.cs" company="Microsoft">
//    Copyright (c) Microsoft Corporation.  All rights reserved.
//    
//    The use and distribution terms for this software are covered by the
//    Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
//    which can be found in the file CPL.TXT at the root of this distribution.
//    By using this software in any fashion, you are agreeing to be bound by
//    the terms of this license.
//    
//    You must not remove this notice, or any other, from this software.
// </copyright>
// 
// <summary>
// Build task to execute the linker of the Windows Installer Xml toolset.
// </summary>
//-------------------------------------------------------------------------------------------------

namespace Microsoft.Tools.WindowsInstallerXml.Build.Tasks{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.IO;
    using System.Text;

    using Microsoft.Build.Framework;
    using Microsoft.Build.Utilities;

    /// <summary>
    /// An MSBuild task to run the WiX linker.
    /// </summary>
    public sealed class Light : WixToolTask
    {
        private const string LightToolName = "Light.exe";

        private string additionalCub;
        private bool allowIdenticalRows;
        private bool allowUnresolvedReferences;
        private string[] baseInputPaths;
        private bool backwardsCompatibleGuidGeneration;
        private bool bindFiles;
        private string cabinetCachePath;
        private int cabinetCreationThreadCount = WixCommandLineBuilder.Unspecified;
        private string cultures;
        private string defaultCompressionLevel;
        private ITaskItem[] extensions;
        private string[] ices;
        private bool leaveTemporaryFiles;
        private ITaskItem[] localizationFiles;
        private ITaskItem[] objectFiles;
        private bool outputAsXml;
        private ITaskItem outputFile;
        private ITaskItem pdbOutputFile;
        private bool pedantic;
        private bool reuseCabinetCache;
        private bool setMsiAssemblyNameFileVersion;
        private bool suppressAclReset;
        private bool suppressAssemblies;
        private bool suppressDefaultAdminSequenceActions;
        private bool suppressDefaultAdvSequenceActions;
        private bool suppressDefaultUISequenceActions;
        private bool dropUnrealTables;
        private bool suppressFileHashAndInfo;
        private bool suppressFiles;
        private bool suppressIntermediateFileVersionMatching;
        private string[] suppressIces;
        private bool suppressLayout;
        private bool suppressLocalization;
        private bool suppressMsiAssemblyTableProcessing;
        private bool suppressPdbOutput;
        private bool suppressSchemaValidation;
        private bool suppressValidation;
        private bool suppressTagSectionIdAttributeOnTuples;
        private ITaskItem unreferencedSymbolsFile;
        private string[] wixVariables;
        private string extensionDirectory;
        private string[] referencePaths;

        /// <summary>
        /// Creates a new light task.
        /// </summary>
        /// <remarks>
        /// Defaults to running the task as a separate process, instead of in-proc
        /// which is the default for WixToolTasks. This allows the Win32 manifest file
        /// embedded in light.exe to enable reg-free COM interop with mergemod.dll.
        /// </remarks>
        public Light()
        {
        }

        public string AdditionalCub
        {
            get { return this.additionalCub; }
            set { this.additionalCub = value; }
        }

        public bool AllowIdenticalRows
        {
            get { return this.allowIdenticalRows; }
            set { this.allowIdenticalRows = value; }
        }

        public bool AllowUnresolvedReferences
        {
            get { return this.allowUnresolvedReferences; }
            set { this.allowUnresolvedReferences = value; }
        }

        public string[] BaseInputPaths
        {
            get { return this.baseInputPaths; }
            set { this.baseInputPaths = value; }
        }

        public bool BackwardsCompatibleGuidGeneration
        {
            get { return this.backwardsCompatibleGuidGeneration; }
            set { this.backwardsCompatibleGuidGeneration = value; }
        }

        public bool BindFiles
        {
            get { return this.bindFiles; }
            set { this.bindFiles = value; }
        }

        public string CabinetCachePath
        {
            get { return this.cabinetCachePath; }
            set { this.cabinetCachePath = value; }
        }

        public int CabinetCreationThreadCount
        {
            get { return this.cabinetCreationThreadCount; }
            set { this.cabinetCreationThreadCount = value; }
        }

        public string Cultures
        {
            get { return this.cultures; }
            set { this.cultures = value; }
        }

        public string DefaultCompressionLevel
        {
            get { return this.defaultCompressionLevel; }
            set { this.defaultCompressionLevel = value; }
        }

        public bool DropUnrealTables
        {
            get { return this.dropUnrealTables; }
            set { this.dropUnrealTables = value; }
        }

        public ITaskItem[] Extensions
        {
            get { return this.extensions; }
            set { this.extensions = value; }
        }

        public string[] Ices
        {
            get { return this.ices; }
            set { this.ices = value; }
        }

        public bool LeaveTemporaryFiles
        {
            get { return this.leaveTemporaryFiles; }
            set { this.leaveTemporaryFiles = value; }
        }

        public ITaskItem[] LocalizationFiles
        {
            get { return this.localizationFiles; }
            set { this.localizationFiles = value; }
        }

        [Required]
        public ITaskItem[] ObjectFiles
        {
            get { return this.objectFiles; }
            set { this.objectFiles = value; }
        }

        public bool OutputAsXml
        {
            get { return this.outputAsXml; }
            set { this.outputAsXml = value; }
        }

        [Required]
        [Output]
        public ITaskItem OutputFile
        {
            get { return this.outputFile; }
            set { this.outputFile = value; }
        }

        [Output]
        public ITaskItem PdbOutputFile
        {
            get { return this.pdbOutputFile; }
            set { this.pdbOutputFile = value; }
        }

        public bool Pedantic
        {
            get { return this.pedantic; }
            set { this.pedantic = value; }
        }

        public bool ReuseCabinetCache
        {
            get { return this.reuseCabinetCache; }
            set { this.reuseCabinetCache = value; }
        }

        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        public bool SetMsiAssemblyNameFileVersion
        {
            get { return this.setMsiAssemblyNameFileVersion; }
            set { this.setMsiAssemblyNameFileVersion = value; }
        }

        public bool SuppressAclReset
        {
            get { return this.suppressAclReset; }
            set { this.suppressAclReset = value; }
        }

        public bool SuppressAssemblies
        {
            get { return this.suppressAssemblies; }
            set { this.suppressAssemblies = value; }
        }

        public bool SuppressDefaultAdminSequenceActions
        {
            get { return this.suppressDefaultAdminSequenceActions; }
            set { this.suppressDefaultAdminSequenceActions = value; }
        }

        public bool SuppressDefaultAdvSequenceActions
        {
            get { return this.suppressDefaultAdvSequenceActions; }
            set { this.suppressDefaultAdvSequenceActions = value; }
        }

        public bool SuppressDefaultUISequenceActions
        {
            get { return this.suppressDefaultUISequenceActions; }
            set { this.suppressDefaultUISequenceActions = value; }
        }

        public bool SuppressFileHashAndInfo
        {
            get { return this.suppressFileHashAndInfo; }
            set { this.suppressFileHashAndInfo = value; }
        }

        public bool SuppressFiles
        {
            get { return this.suppressFiles; }
            set { this.suppressFiles = value; }
        }

        public bool SuppressIntermediateFileVersionMatching
        {
            get { return this.suppressIntermediateFileVersionMatching; }
            set { this.suppressIntermediateFileVersionMatching = value; }
        }

        public string[] SuppressIces
        {
            get { return this.suppressIces; }
            set { this.suppressIces = value; }
        }

        public bool SuppressLayout
        {
            get { return this.suppressLayout; }
            set { this.suppressLayout = value; }
        }

        public bool SuppressLocalization
        {
            get { return this.suppressLocalization; }
            set { this.suppressLocalization = value; }
        }

        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        public bool SuppressMsiAssemblyTableProcessing
        {
            get { return this.suppressMsiAssemblyTableProcessing; }
            set { this.suppressMsiAssemblyTableProcessing = value; }
        }

        public bool SuppressPdbOutput
        {
            get { return this.suppressPdbOutput; }
            set { this.suppressPdbOutput = value; }
        }

        public bool SuppressSchemaValidation
        {
            get { return this.suppressSchemaValidation; }
            set { this.suppressSchemaValidation = value; }
        }

        public bool SuppressValidation
        {
            get { return this.suppressValidation; }
            set { this.suppressValidation = value; }
        }

        public bool SuppressTagSectionIdAttributeOnTuples
        {
            get { return this.suppressTagSectionIdAttributeOnTuples; }
            set { this.suppressTagSectionIdAttributeOnTuples = value; }
        }

        public ITaskItem UnreferencedSymbolsFile
        {
            get { return this.unreferencedSymbolsFile; }
            set { this.unreferencedSymbolsFile = value; }
        }

        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        public string[] WixVariables
        {
            get { return this.wixVariables; }
            set { this.wixVariables = value; }
        }

        public string ExtensionDirectory
        {
            get { return this.extensionDirectory; }
            set { this.extensionDirectory = value; }
        }

        public string[] ReferencePaths
        {
            get { return this.referencePaths; }
            set { this.referencePaths = value; }
        }

        /// <summary>
        /// Get the name of the executable.
        /// </summary>
        /// <remarks>The ToolName is used with the ToolPath to get the location of light.exe.</remarks>
        /// <value>The name of the executable.</value>
        protected override string ToolName
        {
            get { return LightToolName; }
        }

        /// <summary>
        /// Get the path to the executable. 
        /// </summary>
        /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
        /// <returns>The full path to the executable or simply light.exe if it's expected to be in the system path.</returns>
        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 LightToolName;
            }

            return Path.Combine(Path.GetFullPath(this.ToolPath), LightToolName);
        }

        /// <summary>
        /// Builds a command line from options in this task.
        /// </summary>
        protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
        {
            base.BuildCommandLine(commandLineBuilder);

            commandLineBuilder.AppendIfTrue("-ai", this.AllowIdenticalRows);
            commandLineBuilder.AppendIfTrue("-au", this.AllowUnresolvedReferences);
            commandLineBuilder.AppendArrayIfNotNull("-b ", this.BaseInputPaths);
            commandLineBuilder.AppendIfTrue("-bcgg", this.BackwardsCompatibleGuidGeneration);
            commandLineBuilder.AppendIfTrue("-bf", this.BindFiles);
            commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath);
            commandLineBuilder.AppendIfSpecified("-ct ", this.CabinetCreationThreadCount);
            commandLineBuilder.AppendSwitchIfNotNull("-cub ", this.AdditionalCub);
            commandLineBuilder.AppendSwitchIfNotNull("-cultures:", this.Cultures);
            commandLineBuilder.AppendArrayIfNotNull("-d", this.WixVariables);
            commandLineBuilder.AppendSwitchIfNotNull("-dcl:", this.DefaultCompressionLevel);
            commandLineBuilder.AppendIfTrue("-dut", this.DropUnrealTables);
            commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
            commandLineBuilder.AppendIfTrue("-fv", this.SetMsiAssemblyNameFileVersion);
            commandLineBuilder.AppendArrayIfNotNull("-ice:", this.Ices);
            commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
            commandLineBuilder.AppendIfTrue("-notidy", this.LeaveTemporaryFiles);
            commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
            commandLineBuilder.AppendSwitchIfNotNull("-pdbout ", this.PdbOutputFile);
            commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
            commandLineBuilder.AppendIfTrue("-reusecab", this.ReuseCabinetCache);
            commandLineBuilder.AppendIfTrue("-sa", this.SuppressAssemblies);
            commandLineBuilder.AppendIfTrue("-sacl", this.SuppressAclReset);
            commandLineBuilder.AppendIfTrue("-sadmin", this.SuppressDefaultAdminSequenceActions);
            commandLineBuilder.AppendIfTrue("-sadv", this.SuppressDefaultAdvSequenceActions);
            commandLineBuilder.AppendArrayIfNotNull("-sice:", this.SuppressIces);
            commandLineBuilder.AppendIfTrue("-sma", this.SuppressMsiAssemblyTableProcessing);
            commandLineBuilder.AppendIfTrue("-sf", this.SuppressFiles);
            commandLineBuilder.AppendIfTrue("-sh", this.SuppressFileHashAndInfo);
            commandLineBuilder.AppendIfTrue("-sl", this.SuppressLayout);
            commandLineBuilder.AppendIfTrue("-sloc", this.SuppressLocalization);
            commandLineBuilder.AppendIfTrue("-spdb", this.SuppressPdbOutput);
            commandLineBuilder.AppendIfTrue("-ss", this.SuppressSchemaValidation);
            commandLineBuilder.AppendIfTrue("-sts", this.SuppressTagSectionIdAttributeOnTuples);
            commandLineBuilder.AppendIfTrue("-sui", this.SuppressDefaultUISequenceActions);
            commandLineBuilder.AppendIfTrue("-sv", this.SuppressIntermediateFileVersionMatching);
            commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation);
            commandLineBuilder.AppendSwitchIfNotNull("-usf", this.UnreferencedSymbolsFile);
            commandLineBuilder.AppendIfTrue("-xo", this.OutputAsXml);
            commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);

            List<string> objectFilePaths = AdjustFilePaths(this.objectFiles, this.ReferencePaths);
            commandLineBuilder.AppendFileNamesIfNotNull(objectFilePaths.ToArray(), " ");
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.