4 // Rolf Bjarne Kvinge (rolf@xamarin.com)
5 // Atsushi Enomoto (atsushi@xamarin.com)
7 // Copyright (C) 2011,2013 Xamarin Inc.
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using Microsoft.Build.Evaluation;
30 using Microsoft.Build.Framework;
31 using Microsoft.Build.Logging;
33 using System.Collections.Generic;
34 using System.Globalization;
36 using System.Threading;
37 using System.Collections;
39 namespace Microsoft.Build.Execution
41 public class BuildParameters
43 public BuildParameters ()
44 : this (new ProjectCollection ())
48 public BuildParameters (ProjectCollection projectCollection)
50 if (projectCollection == null)
51 throw new ArgumentNullException ("projectCollection");
52 projects = projectCollection;
54 EnableNodeReuse = true;
55 Culture = CultureInfo.CurrentCulture;
56 UICulture = CultureInfo.CurrentUICulture;
57 MaxNodeCount = projectCollection.MaxNodeCount;
59 // these properties are copied, while some members (such as Loggers) are not.
60 this.DefaultToolsVersion = projectCollection.DefaultToolsVersion;
61 this.ToolsetDefinitionLocations = projectCollection.ToolsetLocations;
62 this.GlobalProperties = projectCollection.GlobalProperties;
63 environment_properties = new Dictionary<string,string> ();
64 foreach (DictionaryEntry p in Environment.GetEnvironmentVariables ())
65 environment_properties [(string) p.Key] = (string) p.Value;
68 readonly ProjectCollection projects;
69 Dictionary<string,string> environment_properties;
71 internal ProjectCollection ProjectCollection {
72 get { return projects; }
75 public BuildParameters Clone ()
77 var ret = (BuildParameters) MemberwiseClone ();
78 ret.ForwardingLoggers = ForwardingLoggers == null ? null : ForwardingLoggers.ToArray ();
79 ret.GlobalProperties = GlobalProperties == null ? null : GlobalProperties.ToDictionary (p => p.Key, p => p.Value);
80 ret.Loggers = Loggers == null ? null : new List<ILogger> (Loggers);
81 ret.environment_properties = new Dictionary<string, string> (environment_properties);
85 public Toolset GetToolset (string toolsVersion)
88 return projects.Toolsets.FirstOrDefault (t => t.ToolsVersion == toolsVersion);
92 public ThreadPriority BuildThreadPriority { get; set; }
95 public CultureInfo Culture { get; set; }
97 public string DefaultToolsVersion { get; set; }
100 public bool DetailedSummary { get; set; }
102 public bool EnableNodeReuse { get; set; }
105 public IDictionary<string, string> EnvironmentProperties {
106 get { return environment_properties; }
110 public IEnumerable<ForwardingLoggerRecord> ForwardingLoggers { get; set; }
113 public IDictionary<string, string> GlobalProperties { get; set; }
115 public HostServices HostServices { get; set; }
118 public bool LegacyThreadingSemantics { get; set; }
121 public IEnumerable<ILogger> Loggers { get; set; }
124 public int MaxNodeCount { get; set; }
127 public int MemoryUseLimit { get; set; }
130 public string NodeExeLocation { get; set; }
133 public bool OnlyLogCriticalEvents { get; set; }
136 public bool ResetCaches { get; set; }
139 public bool SaveOperatingEnvironment { get; set; }
142 public ToolsetDefinitionLocations ToolsetDefinitionLocations { get; set; }
145 public ICollection<Toolset> Toolsets {
146 get { return projects.Toolsets; }
150 public CultureInfo UICulture { get; set; }
153 public bool UseSynchronousLogging { get; set; }