2 // ProjectCollection.cs
5 // Leszek Ciesielski (skolima@gmail.com)
6 // Rolf Bjarne Kvinge (rolf@xamarin.com)
8 // (C) 2011 Leszek Ciesielski
9 // Copyright (C) 2011 Xamarin Inc.
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using Microsoft.Build.Construction;
32 using Microsoft.Build.Execution;
33 using Microsoft.Build.Framework;
34 using Microsoft.Build.Logging;
35 using Microsoft.Build.Utilities;
37 using System.Collections.Generic;
38 using System.Collections.ObjectModel;
42 namespace Microsoft.Build.Evaluation
44 public class ProjectCollection : IDisposable
48 static readonly ProjectCollection global_project_collection;
50 static ProjectCollection ()
53 global_project_collection = new ProjectCollection (new ReadOnlyDictionary<string, string> (new Dictionary<string, string> ()));
55 global_project_collection = new ProjectCollection (new Dictionary<string, string> ());
59 public static string Escape (string unescapedString)
61 return unescapedString;
64 public static ProjectCollection GlobalProjectCollection {
65 get { return global_project_collection; }
68 // semantic model part
70 public ProjectCollection ()
75 public ProjectCollection (IDictionary<string, string> globalProperties)
76 : this (globalProperties, null, ToolsetDefinitionLocations.Registry | ToolsetDefinitionLocations.ConfigurationFile)
80 public ProjectCollection (ToolsetDefinitionLocations toolsetDefinitionLocations)
81 : this (null, null, toolsetDefinitionLocations)
85 public ProjectCollection (IDictionary<string, string> globalProperties, IEnumerable<ILogger> loggers,
86 ToolsetDefinitionLocations toolsetDefinitionLocations)
87 : this (globalProperties, loggers, null, toolsetDefinitionLocations, int.MaxValue, false)
91 public ProjectCollection (IDictionary<string, string> globalProperties,
92 IEnumerable<ILogger> loggers, IEnumerable<ForwardingLoggerRecord> remoteLoggers,
93 ToolsetDefinitionLocations toolsetDefinitionLocations,
94 int maxNodeCount, bool onlyLogCriticalEvents)
96 global_properties = globalProperties ?? new Dictionary<string, string> ();
97 this.loggers = loggers != null ? loggers.ToList () : new List<ILogger> ();
98 toolset_locations = toolsetDefinitionLocations;
99 max_node_count = maxNodeCount;
100 OnlyLogCriticalEvents = onlyLogCriticalEvents;
102 LoadDefaultToolsets ();
105 readonly int max_node_count;
109 get { return loaded_projects.Count; }
113 public string DefaultToolsVersion {
114 get { throw new NotImplementedException (); }
117 public void Dispose ()
120 GC.SuppressFinalize (this);
123 protected virtual void Dispose (bool disposing)
129 public ICollection<Project> GetLoadedProjects (string fullPath)
131 return LoadedProjects.Where (p => Path.GetFullPath (p.FullPath) == Path.GetFullPath (fullPath)).ToList ();
134 readonly IDictionary<string, string> global_properties;
136 public IDictionary<string, string> GlobalProperties {
137 get { return global_properties; }
140 readonly List<Project> loaded_projects = new List<Project> ();
143 public ICollection<Project> LoadedProjects {
144 get { return loaded_projects; }
147 readonly List<ILogger> loggers = new List<ILogger> ();
149 public ICollection<ILogger> Loggers {
150 get { return loggers; }
154 public bool OnlyLogCriticalEvents { get; set; }
157 public bool SkipEvaluation { get; set; }
159 readonly ToolsetDefinitionLocations toolset_locations;
160 public ToolsetDefinitionLocations ToolsetLocations {
161 get { return toolset_locations; }
164 readonly List<Toolset> toolsets = new List<Toolset> ();
165 [MonoTODO ("unused")]
166 // so what should we do without ToolLocationHelper in Microsoft.Build.Utilities.dll? There is no reference to it in this dll.
167 public ICollection<Toolset> Toolsets {
168 // For ConfigurationFile and None, they cannot be added externally.
169 get { return (ToolsetLocations & ToolsetDefinitionLocations.Registry) != 0 ? toolsets : toolsets.ToList (); }
172 //FIXME: should also support config file, depending on ToolsetLocations
173 void LoadDefaultToolsets ()
175 toolsets.Add (new Toolset ("2.0",
176 ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20), this, null));
177 toolsets.Add (new Toolset ("3.0",
178 ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version30), this, null));
179 toolsets.Add (new Toolset ("3.5",
180 ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version35), this, null));
182 toolsets.Add (new Toolset ("4.0",
183 ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40), this, null));
186 toolsets.Add (new Toolset ("4.5",
187 ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version45), this, null));
191 public void UnloadAllProjects ()
193 throw new NotImplementedException ();
196 public void UnloadProject (Project project)
198 throw new NotImplementedException ();
201 public void UnloadProject (ProjectRootElement projectRootElement)
203 throw new NotImplementedException ();
206 public static Version Version {
207 get { throw new NotImplementedException (); }
213 public bool DisableMarkDirty { get; set; }
216 public HostServices HostServices { get; set; }
219 public bool IsBuildEnabled { get; set; }