Lit.cs :  » Installers-Generators » WiX » Microsoft » Tools » WindowsInstallerXml » Test » 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 » Test » Lit.cs
//-----------------------------------------------------------------------
// <copyright file="Lit.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>A class that wraps Lit</summary>
//-----------------------------------------------------------------------

namespace Microsoft.Tools.WindowsInstallerXml.Test{
    using System;
    using System.IO;
    using System.Collections.Generic;

    /// <summary>
    /// A class that wraps Lit
    /// </summary>
    public partial class Lit : WixTool
    {
        /// <summary>
        /// Default output extension for Lit output
        /// </summary>
        private const string OutputFileExtension = ".wixlib";

        /// <summary>
        /// Constructor that uses the current directory as the working directory
        /// </summary>
        public Lit()
            : this(String.Empty)
        {
        }

        /// <summary>
        /// Constructor that uses the default WiX tool directory as the tools location
        /// </summary>
        /// <param name="workingDirectory">The working directory of the tool</param>
        public Lit(string workingDirectory)
            : base("lit.exe", workingDirectory)
        {
            SetDefaultOutputFile();
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="toolDirectory">The directory of the tool</param>
        /// <param name="workingDirectory">The working directory of the tool</param>
        public Lit(string toolDirectory, string workingDirectory)
            : base(toolDirectory, "lit.exe", workingDirectory)
        {
            SetDefaultOutputFile();
        }

        /// <summary>
        /// Constructor that uses data from a Candle object to create a Lit object
        /// </summary>
        /// <param name="candle">A Candle object</param>
        public Lit(Candle candle)
            : base(Path.GetDirectoryName(candle.ToolFile), "lit.exe", candle.WorkingDirectory)
        {
            // The output of Candle is the input for Lit
            this.ObjectFiles = candle.ExpectedOutputFiles;
            SetDefaultOutputFile();
        }
        /// <summary>
        /// Run the tool.
        /// </summary>
        /// <param name="exceptionOnError">If true, throw an exception when expected results don't match actual results.</param>
        /// <returns>The results of the run.</returns>
        public override Result Run(bool exceptionOnError)
        {
            return base.Run(exceptionOnError);
        }

        /// <summary>
        /// Checks that the result from a run matches the expected results.
        /// </summary>
        /// <param name="result">A result from a run.</param>
        /// <returns>A list of errors.</returns>
        public override List<string> CheckResult(Result result)
        {
            List<string> errors = new List<string>();
            errors.AddRange(base.CheckResult(result));

            // If Lit returns success then verify that expected wix file is created
            if (result.ExitCode == 0)
            {
                if (null != this.ObjectFiles && this.ObjectFiles.Count > 0)
                {
                    if (false == this.Help && !File.Exists(this.ExpectedOutputFile))
                    {
                        errors.Add(String.Format("Expected wix file {0} was not created", this.ExpectedOutputFile));
                    }
                }
            }
            return errors;
        }

        /// <summary>
        /// The expected output file of Lit that is guaranteed to exist
        /// </summary>
        public string ExpectedOutputFile
        {
            get
            {
                if (!string.IsNullOrEmpty(this.OutputFile))
                {
                    return this.OutputFile;
                }
                else
                {
                    if (null != this.ObjectFiles && 1 == this.ObjectFiles.Count)
                    {
                        return Path.Combine(this.WorkingDirectory, String.Concat(Path.GetFileNameWithoutExtension(this.ObjectFiles[0]), Lit.OutputFileExtension));
                    }
                    else
                    {
                        return Path.Combine(this.WorkingDirectory, String.Concat("product", Lit.OutputFileExtension));
                    }
                }
            }
        }

        /// <summary>
        /// Functional name of the tool
        /// </summary>
        public override string ToolDescription
        {
            get { return "Library Tool"; }
        }

        /// <summary>
        /// Sets the output file as Lit to a temporary directory
        /// </summary>
        private void SetDefaultOutputFile()
        {
            DirectoryInfo tempDirectory = Directory.CreateDirectory(Builder.GetUniqueFileName());

            if (null != this.ObjectFiles && 1 == this.ObjectFiles.Count)
            {
                this.OutputFile = Path.Combine(tempDirectory.FullName, String.Concat(Path.GetFileNameWithoutExtension(this.ObjectFiles[0]), Lit.OutputFileExtension));
            }
            else
            {
                this.OutputFile = Path.Combine(tempDirectory.FullName, String.Concat("product", Lit.OutputFileExtension));
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.