MSBuildArguments.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 » MSBuildArguments.cs
//-----------------------------------------------------------------------
// <copyright file="MSBuildArguments.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>
//     Fields, properties and methods for working with MSBuild arguments
// </summary>
//-----------------------------------------------------------------------

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

    /// <summary>
    /// Fields, properties and methods for working with MSBuild arguments.
    /// </summary>
    public partial class MSBuild
    {
        /// <summary>
        /// The MSBuild verbosity level
        /// </summary>
        public enum VerbosityLevel
        {
            /// <summary>
            /// Minimal
            /// </summary>
            Minimal = 0,

            /// <summary>
            /// Normal
            /// </summary>
            Normal,

            /// <summary>
            /// Detailed
            /// </summary>
            Detailed,

            /// <summary>
            /// Diagnostics
            /// </summary>
            Diagnostics
        }

        #region Private Members

        /// <summary>
        /// Specifies the maximum number of concurrent processes to build with.
        /// </summary>
        /// <remarks>
        /// Defaults to the number of CPUs on the current machine.
        /// </remarks>
        private int maxCPUCount;

        /// <summary>
        /// Do not display the startup banner and copyright message.
        /// </summary>
        private bool noLogo;

        /// <summary>
        /// Other arguments.
        /// </summary>
        private string otherArguments;

        /// <summary>
        /// The project file to build.
        /// </summary>
        private string projectFile;

        /// <summary>
        /// Set or override project-level properties.
        /// </summary>
        private Dictionary<string, string> properties;

        /// <summary>
        /// Build these targets in the project.
        /// </summary>
        private List<string> targets;

        /// <summary>
        /// The version of the MSBuild Toolset to use during build.
        /// </summary>
        private string toolsVersion;

        /// <summary>
        /// Display this amount of information in the event log.
        /// </summary>
        private VerbosityLevel verbosity;

        #endregion

        #region Public Properties

        /// <summary>
        /// The arguments as they would be passed on the command line.
        /// </summary>
        /// <remarks>
        /// To allow for negative testing, checking for invalid combinations
        /// of arguments is not performed.
        /// </remarks>
        public override string Arguments
        {
            get
            {
                StringBuilder arguments = new StringBuilder();

                // MaxCPUCount
                if (0 == this.MaxCPUCount)
                {
                    // Use the number of CPUs on this machine
                    arguments.Append(" /maxcpucount");
                }
                else if (0 < this.MaxCPUCount)
                {
                    arguments.AppendFormat(" /maxcpucount:{0}", Convert.ToString(this.MaxCPUCount));
                }

                // NoLogo
                if (this.NoLogo)
                {
                    arguments.Append(" /nologo");
                }

                // OtherArguments
                if (!String.IsNullOrEmpty(this.OtherArguments))
                {
                    arguments.AppendFormat(" {0}", this.OtherArguments);
                }

                // Properties
                foreach (string key in this.Properties.Keys)
                {
                    arguments.AppendFormat(" /property:{0}=\"{1}\"", key, this.Properties[key]);
                }

                // Targets
                foreach (string target in this.Targets)
                {
                    arguments.AppendFormat(" /target:{0}", target);
                }

                // ToolsVersion
                if (!String.IsNullOrEmpty(this.ToolsVersion))
                {
                    arguments.AppendFormat(" /toolsversion:{0}", this.ToolsVersion);
                }

                // Verbosity
                switch (this.Verbosity)
                {
                    case VerbosityLevel.Minimal:
                    case VerbosityLevel.Normal:
                    case VerbosityLevel.Detailed:
                    case VerbosityLevel.Diagnostics:
                        arguments.AppendFormat(" /verbosity:{0}", Enum.GetName(typeof(VerbosityLevel), this.Verbosity));
                        break;
                    default:
                        // do nothing
                        break;
                }

                // ProjectFile
                if (!String.IsNullOrEmpty(this.ProjectFile))
                {
                    arguments.AppendFormat(" \"{0}\"", this.ProjectFile);
                }

                return arguments.ToString();
            }
        }

        /// <summary>
        /// Specifies the maximum number of concurrent processes to build with.
        /// </summary>
        /// <remarks>
        /// Defaults to the number of CPUs on the current machine.
        /// </remarks>
        public int MaxCPUCount
        {
            get { return this.maxCPUCount; }
            set { this.maxCPUCount = value; }
        }

        /// <summary>
        /// Do not display the startup banner and copyright message.
        /// </summary>
        public bool NoLogo
        {
            get { return this.noLogo; }
            set { this.noLogo = value; }
        }

        /// <summary>
        /// Other arguments.
        /// </summary>
        public string OtherArguments
        {
            get { return this.otherArguments; }
            set { this.otherArguments = value; }
        }

        /// <summary>
        /// The project file to build.
        /// </summary>
        public string ProjectFile
        {
            get { return this.projectFile; }
            set { this.projectFile = value; }
        }

        /// <summary>
        /// Set or override project-level properties.
        /// </summary>
        public Dictionary<string, string> Properties
        {
            get { return this.properties; }
            set { this.properties = value; }
        }

        /// <summary>
        /// Build these targets in the project.
        /// </summary>
        public List<string> Targets
        {
            get { return this.targets; }
            set { this.targets = value; }
        }

        /// <summary>
        /// The version of the MSBuild Toolset to use during build.
        /// </summary>
        public string ToolsVersion
        {
            get { return this.toolsVersion; }
            set { this.toolsVersion = value; }
        }

        /// <summary>
        /// Display this amount of information in the event log.
        /// </summary>
        public VerbosityLevel Verbosity
        {
            get { return this.verbosity; }
            set { this.verbosity = value; }
        }

        #endregion

        /// <summary>
        /// Clears all of the assigned arguments and resets them to the default values.
        /// </summary>
        public void SetDefaultArguments()
        {
            this.MaxCPUCount = 0;
            this.NoLogo = true;
            this.OtherArguments = String.Empty;
            this.ProjectFile = String.Empty;
            this.Properties = new Dictionary<string, string>();
            this.Targets = new List<string>();
            this.ToolsVersion = String.Empty;
            this.Verbosity = VerbosityLevel.Detailed;
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.