Ejemplo n.º 1
0
		public xTargetBuilder(CSBuildConfig config, BuildTarget target, string[] properties)
		{
			_config = config;
			_target = Check.NotNull(target);
			_build = BuildList.CreateInstance(_target.Toolset.ToString().Insert(2, ".").TrimStart('v'), _target.FrameworkPath,
                GetReferenceFolders().Length > 0);
			
			new TargetBuilderDispatch(this, _build);

			if (config.Console != null)
				_build.SetConsoleLevel(config.Console.Level);
            if (_target.TextLog != null)
                _build.SetTextLogFile(Environment.CurrentDirectory, _target.TextLog.AbsolutePath, _target.TextLog.Level);
            if (_target.XmlLog != null)
                _build.SetXmlLogFile(Environment.CurrentDirectory, _target.XmlLog.AbsolutePath, _target.XmlLog.Level);

			_build.SetProperty("Configuration", _target.Configuration);
			_build.SetProperty("Platform", _target.Platform.ToString());

			foreach (string property in properties)
			{
				string[] values = property.Split( new char [] { '=', ':' }, 2);
				if (values.Length == 2)
				{
					Log.Verbose("Setting property {0} = {1}", values[0], values[1]);
					_build.SetProperty(values[0], values[1]);
				}
			}

			Log.Info("Using Configuration = {0}", _build.GetProperty("Configuration"));
			Log.Info("Using Platform = {0}", _build.GetProperty("Platform"));
		}
Ejemplo n.º 2
0
 public CmdLineBuilder(CSBuildConfig config, LoggerVerbosity?verbosity, string groups, string[] targetNames, string[] propertySets)
 {
     _config       = config;
     _verbosity    = verbosity;
     _groups       = groups;
     _targetNames  = targetNames;
     _propertySets = propertySets;
     _thread       = new System.Threading.Thread(this.Build);
 }
Ejemplo n.º 3
0
		public CmdLineBuilder(CSBuildConfig config, LoggerVerbosity? verbosity, string groups, string[] targetNames, string[] propertySets)
		{
			_config = config;
			_verbosity = verbosity;
			_groups = groups;
			_targetNames = targetNames;
			_propertySets = propertySets;
			_thread = new System.Threading.Thread(this.Build);
		}
Ejemplo n.º 4
0
        public TargetBuilder(CSBuildConfig config, BuildTarget target, string[] properties, string[] targets)
        {
            _config = config;
            _target = target;
            _properties = CSBuildConfig.ToDictionary(properties);
            _namedValues = new Dictionary<string, string>(_properties, StringComparer.OrdinalIgnoreCase);

            foreach (BuildProperty prop in _target.BuildProperties)
                _namedValues[prop.Name] = Environment.ExpandEnvironmentVariables(prop.Value);

            _buildTask = new BuildAll(targets);
        }
        public TargetBuilder(CSBuildConfig config, BuildTarget target, string[] properties, string[] targets)
        {
            _config      = config;
            _target      = target;
            _properties  = CSBuildConfig.ToDictionary(properties);
            _namedValues = new Dictionary <string, string>(_properties, StringComparer.OrdinalIgnoreCase);

            foreach (BuildProperty prop in _target.BuildProperties)
            {
                _namedValues[prop.Name] = Environment.ExpandEnvironmentVariables(prop.Value);
            }

            _buildTask = new BuildAll(targets);
        }
        public xTargetBuilder(CSBuildConfig config, BuildTarget target, string[] properties)
        {
            _config = config;
            _target = Check.NotNull(target);
            _build  = BuildList.CreateInstance(_target.Toolset.ToString().Insert(2, ".").TrimStart('v'), _target.FrameworkPath,
                                               GetReferenceFolders().Length > 0);

            new TargetBuilderDispatch(this, _build);

            if (config.Console != null)
            {
                _build.SetConsoleLevel(config.Console.Level);
            }
            if (_target.TextLog != null)
            {
                _build.SetTextLogFile(Environment.CurrentDirectory, _target.TextLog.AbsolutePath, _target.TextLog.Level);
            }
            if (_target.XmlLog != null)
            {
                _build.SetXmlLogFile(Environment.CurrentDirectory, _target.XmlLog.AbsolutePath, _target.XmlLog.Level);
            }

            _build.SetProperty("Configuration", _target.Configuration);
            _build.SetProperty("Platform", _target.Platform.ToString());

            foreach (string property in properties)
            {
                string[] values = property.Split(new char [] { '=', ':' }, 2);
                if (values.Length == 2)
                {
                    Log.Verbose("Setting property {0} = {1}", values[0], values[1]);
                    _build.SetProperty(values[0], values[1]);
                }
            }

            Log.Info("Using Configuration = {0}", _build.GetProperty("Configuration"));
            Log.Info("Using Platform = {0}", _build.GetProperty("Platform"));
        }
Ejemplo n.º 7
0
        static int Main(string[] argsRaw)
        {
            int          errors    = 0;
            ArgumentList arguments = new ArgumentList(argsRaw);

            if (!arguments.Contains("nologo"))
            {
                Console.WriteLine("{0}", typeof(Program).Assembly);
                foreach (System.Reflection.AssemblyCopyrightAttribute a in typeof(Program).Assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyCopyrightAttribute), false))
                {
                    Console.WriteLine("{0}", a.Copyright);
                }
                Console.WriteLine(".NET Runtime Version={0}", System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion());
            }

            if (arguments.Contains("?") || arguments.Contains("help"))
            {
                return(ShowHelp(Console.Out));
            }

            Log.Open(TextWriter.Null);
            Log.ConsoleLevel = arguments.Contains("verbose") ? TraceLevel.Verbose : TraceLevel.Warning;
            try
            {
                CSBuildConfig config = null;

                if (arguments.Contains("config"))
                {
                    using (System.Xml.XmlReader rdr = new System.Xml.XmlTextReader(arguments["config"]))
                        config = Config.ReadXml(Config.SCHEMA_NAME, rdr);
                }
                else
                {
                    config = Config.ReadConfig("CSBuildConfig");
                }

                if (config == null)
                {
                    throw new ApplicationException("Unable to locate configuration section 'CSBuildConfig', and no /config= option was given.");
                }

                string logfile = config.Options.LogPath(new Dictionary <string, string>());
                if (arguments.Contains("log"))
                {
                    logfile = Path.GetFullPath(arguments["log"]);
                }

                if (logfile != null)
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(logfile));
                    Log.Open(TextWriter.Synchronized(new StreamWriter(File.Open(logfile, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Delete))));
                    if (config.Options.ConsoleEnabled)
                    {
                        Log.ConsoleLevel = arguments.Contains("verbose") ? TraceLevel.Verbose : !arguments.Contains("quiet") ? TraceLevel.Info : TraceLevel.Warning;
                    }
                }

                List <string> propertySets = new List <string>();
                foreach (BuildProperty p in config.Options.GlobalProperties)
                {
                    propertySets.Add(String.Format("{0}={1}", p.Name, p.Value));
                }
                if (config.Options.ImportOptionsFile != null)
                {
                    try
                    {
                        string fpath = config.Options.ImportOptionsFile.AbsolutePath(new Dictionary <string, string>());
                        propertySets.AddRange(File.ReadAllLines(fpath));
                    }
                    catch (FileNotFoundException e)
                    { throw new ApplicationException("Unable to locate options file: " + e.FileName, e); }
                }
                propertySets.AddRange(arguments.SafeGet("p").Values);
                propertySets.AddRange(arguments.SafeGet("property").Values);

                using (Log.AppStart(Environment.CommandLine))
                    using (Log.Start("Build started {0}", DateTime.Now))
                    {
                        LoggerVerbosity?verbosity = config.Options.ConsoleLevel;
                        if (arguments.Contains("quiet"))
                        {
                            verbosity = LoggerVerbosity.Quiet;
                        }
                        else if (arguments.Contains("verbose"))
                        {
                            verbosity = LoggerVerbosity.Normal;
                        }
                        else if (arguments.Contains("verbosity"))
                        {
                            verbosity = (LoggerVerbosity)Enum.Parse(typeof(LoggerVerbosity), arguments["verbosity"], true);
                        }

                        string[] targetNames = new List <string>(arguments.Unnamed).ToArray();

                        using (CmdLineBuilder b = new CmdLineBuilder(config, verbosity, arguments.SafeGet("group"), targetNames, propertySets.ToArray()))
                        {
                            b.Start();
                            errors += b.Complete(TimeSpan.FromHours(config.Options.TimeoutHours));
                        }
                    }
            }
            catch (ApplicationException ae)
            {
                Log.Verbose(ae.ToString());
                Log.Error("\r\n{0}", ae.Message);
                errors += 1;
            }
            catch (System.Configuration.ConfigurationException ce)
            {
                Log.Verbose(ce.ToString());
                Log.Error("\r\nConfiguration Exception: {0}", ce.Message);
                errors += 1;
            }
            catch (Exception e)
            {
                Log.Error(e);
                errors += 1;
            }

            if (arguments.Contains("wait"))
            {
                Console.WriteLine();
                Console.WriteLine("Press [Enter] to continue...");
                Console.ReadLine();
            }

            return(errors);
        }