SingleOutputWixTask.cs :  » Installers-Generators » WiX » Microsoft » Tools » WindowsInstallerXml » NAntTasks » 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 » NAntTasks » SingleOutputWixTask.cs
//--------------------------------------------------------------------------------------------------
// <copyright file="SingleOutputWixTask.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>
// Base class for all Wix-related NAnt tasks that have a single output file (lit, light).
// </summary>
//--------------------------------------------------------------------------------------------------

namespace Microsoft.Tools.WindowsInstallerXml.NAntTasks{
    using System;
    using System.IO;
    using System.Xml;

    using NAnt.Core;
    using NAnt.Core.Attributes;
    using NAnt.Core.Tasks;
    using NAnt.Core.Types;

    /// <summary>
    /// Abstract base class for all Wix-related NAnt tasks that have a single output file (lit, light).
    /// </summary>
    public abstract class SingleOutputWixTask : WixTask
    {
        #region Member Variables
        //==========================================================================================
        // Member Variables
        //==========================================================================================

        private FileInfo outputFile;
        #endregion

        #region Constructors
        //==========================================================================================
        // Constructors
        //==========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="SingleOutputWixTask"/> class.
        /// </summary>
        protected SingleOutputWixTask(string exeName) : base(exeName)
        {
        }
        #endregion

        #region Properties
        //==========================================================================================
        // Properties
        //==========================================================================================

        /// <summary>
        /// Gets or sets the output file (-out).
        /// </summary>
        [TaskAttribute("out", Required = true)]
        public FileInfo OutputFile
        {
            get { return this.outputFile; }
            set { this.outputFile = value; }
        }
        #endregion
 
        #region Methods
        //==========================================================================================
        // Methods
        //==========================================================================================

        /// <summary>
        /// Logs any build start messages.
        /// </summary>
        protected override void LogBuildStart()
        {
            string startMessage = Strings.BuildingFiles(this.Sources.FileNames.Count, this.OutputFile.FullName);
            this.Log(Level.Info, startMessage);
        }

        /// <summary>
        /// Returns a value indicating whether the output of this tool needs to be rebuilt (i.e. if
        /// the tool needs to be run).
        /// </summary>
        /// <returns>true if the output of this tool needs to be rebuilt; otherwise, false.</returns>
        protected override bool NeedsRebuilding()
        {
            // Check the base class.
            if (base.NeedsRebuilding())
            {
                return true;
            }

            // If the output file does not exist, rebuild.
            if (!this.OutputFile.Exists)
            {
                this.Log(Level.Verbose, Strings.OutputFileDoesNotExist(this.OutputFile.FullName));
                return true;
            }

            // See if one of the source files has changed since we built last.
            string changedFileName = FileSet.FindMoreRecentLastWriteTime(this.Sources.FileNames, this.OutputFile.LastWriteTime);
            if (changedFileName != null)
            {
                this.Log(Level.Verbose, Strings.FileHasBeenUpdated(changedFileName));
                return true;
            }

            // At this point we've determined that the tool does not need to rebuild anything.
            return false;
        }

        /// <summary>
        /// Writes all of the command-line parameters for the tool to a response file, one parameter per line.
        /// </summary>
        /// <param name="writer">The output writer.</param>
        protected override void WriteOptions(TextWriter writer)
        {
            base.WriteOptions(writer);
            writer.WriteLine("-out " + Utility.QuotePathIfNeeded(this.OutputFile.FullName));
        }
        #endregion
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.