Add [Category ("NotWorking")] to failing test.
[mono.git] / mcs / class / Microsoft.Build.Tasks / Microsoft.Build.Tasks / ResolveAssemblyReference.cs
1 //
2 // ResolveAssemblyReference.cs: Searches for assembly files.
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //   Ankit Jain (jankit@novell.com)
7 // 
8 // (C) 2006 Marek Sieradzki
9 // Copyright 2009 Novell, Inc (http://www.novell.com)
10 //
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:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
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.
29
30 #if NET_2_0
31
32 using System;
33 using System.Collections.Generic;
34 using System.Globalization;
35 using System.IO;
36 using System.Linq;
37 using System.Reflection;
38 using System.Security;
39 using Microsoft.Build.Framework;
40 using Microsoft.Build.Utilities;
41
42 namespace Microsoft.Build.Tasks {
43         public class ResolveAssemblyReference : TaskExtension {
44         
45                 bool            autoUnify;
46                 ITaskItem[]     assemblyFiles;
47                 ITaskItem[]     assemblies;
48                 string          appConfigFile;
49                 string[]        allowedAssemblyExtensions;
50                 string[]        allowedRelatedFileExtensions;
51                 string[]        candidateAssemblyFiles;
52                 ITaskItem[]     copyLocalFiles;
53                 ITaskItem[]     filesWritten;
54                 bool            findDependencies;
55                 bool            findRelatedFiles;
56                 bool            findSatellites;
57                 bool            findSerializationAssemblies;
58                 string[]        installedAssemblyTables;
59                 ITaskItem[]     relatedFiles;
60                 ITaskItem[]     resolvedDependencyFiles;
61                 ITaskItem[]     resolvedFiles;
62                 ITaskItem[]     satelliteFiles;
63                 ITaskItem[]     scatterFiles;
64                 string[]        searchPaths;
65                 ITaskItem[]     serializationAssemblyFiles;
66                 bool            silent;
67                 string          stateFile;
68                 ITaskItem[]     suggestedRedirects;
69                 string[]        targetFrameworkDirectories;
70                 string          targetProcessorArchitecture;
71                 static string []        default_assembly_extensions;
72
73                 AssemblyResolver        assembly_resolver;
74                 List<string> dependency_search_paths;
75                 Dictionary<string, ResolvedReference> assemblyNameToResolvedRef;
76                 Dictionary<string, ITaskItem>   tempSatelliteFiles, tempRelatedFiles,
77                         tempResolvedDepFiles, tempCopyLocalFiles;
78                 List<ITaskItem> tempResolvedFiles;
79                 List<PrimaryReference> primaryReferences;
80                 Dictionary<string, string> alreadyScannedAssemblyNames;
81                 Dictionary<string, string> conflictWarningsCache;
82
83                 //FIXME: construct and use a graph of the dependencies, useful across projects
84
85                 static ResolveAssemblyReference ()
86                 {
87                         default_assembly_extensions = new string [] { ".dll", ".exe" };
88                 }
89
90                 public ResolveAssemblyReference ()
91                 {
92                         assembly_resolver = new AssemblyResolver ();
93                 }
94
95                 //FIXME: make this reusable
96                 public override bool Execute ()
97                 {
98                         if (assemblies == null && assemblyFiles == null)
99                                 // nothing to resolve
100                                 return true;
101
102                         LogTaskParameters ();
103
104                         assembly_resolver.Log = Log;
105                         tempResolvedFiles = new List<ITaskItem> ();
106                         tempCopyLocalFiles = new Dictionary<string, ITaskItem> ();
107                         tempSatelliteFiles = new Dictionary<string, ITaskItem> ();
108                         tempRelatedFiles = new Dictionary<string, ITaskItem> ();
109                         tempResolvedDepFiles = new Dictionary<string, ITaskItem> ();
110
111                         primaryReferences = new List<PrimaryReference> ();
112                         assemblyNameToResolvedRef = new Dictionary<string, ResolvedReference> ();
113                         conflictWarningsCache = new Dictionary<string, string> ();
114
115                         ResolveAssemblies ();
116                         ResolveAssemblyFiles ();
117                         resolvedFiles = tempResolvedFiles.ToArray ();
118
119                         alreadyScannedAssemblyNames = new Dictionary<string, string> ();
120
121                         // the first element is place holder for parent assembly's dir
122                         dependency_search_paths = new List<string> () { String.Empty };
123                         dependency_search_paths.AddRange (searchPaths);
124
125                         // resolve dependencies
126                         foreach (PrimaryReference pref in primaryReferences)
127                                 ResolveAssemblyFileDependencies (pref.TaskItem, pref.ParentCopyLocal);
128
129                         copyLocalFiles = tempCopyLocalFiles.Values.ToArray ();
130                         satelliteFiles = tempSatelliteFiles.Values.ToArray ();
131                         relatedFiles = tempRelatedFiles.Values.ToArray ();
132                         resolvedDependencyFiles = tempResolvedDepFiles.Values.ToArray ();
133
134                         tempResolvedFiles.Clear ();
135                         tempCopyLocalFiles.Clear ();
136                         tempSatelliteFiles.Clear ();
137                         tempRelatedFiles.Clear ();
138                         tempResolvedDepFiles.Clear ();
139                         alreadyScannedAssemblyNames.Clear ();
140                         primaryReferences.Clear ();
141                         assemblyNameToResolvedRef.Clear ();
142                         conflictWarningsCache.Clear ();
143                         dependency_search_paths = null;
144
145                         return true;
146                 }
147
148                 void ResolveAssemblies ()
149                 {
150                         if (assemblies == null || assemblies.Length == 0)
151                                 return;
152
153                         foreach (ITaskItem item in assemblies) {
154                                 if (!String.IsNullOrEmpty (item.GetMetadata ("SubType"))) {
155                                         Log.LogWarning ("Reference '{0}' has non-empty SubType. Ignoring.", item.ItemSpec);
156                                         continue;
157                                 }
158
159                                 LogWithPrecedingNewLine (MessageImportance.Low, "Primary Reference {0}", item.ItemSpec);
160                                 ResolvedReference resolved_ref = ResolveReference (item, searchPaths, true);
161                                 if (resolved_ref == null) {
162                                         Log.LogWarning ("Reference '{0}' not resolved", item.ItemSpec);
163                                         assembly_resolver.LogSearchLoggerMessages (MessageImportance.Normal);
164                                 } else {
165                                         if (Environment.GetEnvironmentVariable ("XBUILD_LOG_REFERENCE_RESOLVER") != null)
166                                                 assembly_resolver.LogSearchLoggerMessages (MessageImportance.Low);
167
168                                         Log.LogMessage (MessageImportance.Low,
169                                                         "\tReference {0} resolved to {1}. CopyLocal = {2}",
170                                                         item.ItemSpec, resolved_ref.TaskItem,
171                                                         resolved_ref.TaskItem.GetMetadata ("CopyLocal"));
172
173                                         Log.LogMessage (MessageImportance.Low,
174                                                         "\tReference found at search path {0}",
175                                                         resolved_ref.FoundInSearchPathAsString);
176
177                                         if (TryAddNewReference (tempResolvedFiles, resolved_ref) &&
178                                                 !IsFromGacOrTargetFramework (resolved_ref) &&
179                                                 resolved_ref.FoundInSearchPath != SearchPath.PkgConfig) {
180                                                 primaryReferences.Add (new PrimaryReference (
181                                                                 resolved_ref.TaskItem,
182                                                                 resolved_ref.TaskItem.GetMetadata ("CopyLocal")));
183                                         }
184                                 }
185                         }
186                 }
187
188                 // Use @search_paths to resolve the reference
189                 ResolvedReference ResolveReference (ITaskItem item, IEnumerable<string> search_paths, bool set_copy_local)
190                 {
191                         ResolvedReference resolved = null;
192                         bool specific_version;
193
194                         assembly_resolver.ResetSearchLogger ();
195
196                         if (!TryGetSpecificVersionValue (item, out specific_version))
197                                 return null;
198
199                         foreach (string spath in search_paths) {
200                                 assembly_resolver.LogSearchMessage ("For searchpath {0}", spath);
201
202                                 if (String.Compare (spath, "{HintPathFromItem}") == 0) {
203                                         resolved = assembly_resolver.ResolveHintPathReference (item, specific_version);
204                                 } else if (String.Compare (spath, "{TargetFrameworkDirectory}") == 0) {
205                                         if (targetFrameworkDirectories == null)
206                                                 continue;
207                                         foreach (string fpath in targetFrameworkDirectories) {
208                                                 resolved = assembly_resolver.FindInTargetFramework (item,
209                                                                 fpath, specific_version);
210                                                 if (resolved != null)
211                                                         break;
212                                         }
213                                 } else if (String.Compare (spath, "{GAC}") == 0) {
214                                         resolved = assembly_resolver.ResolveGacReference (item, specific_version);
215                                 } else if (String.Compare (spath, "{RawFileName}") == 0) {
216                                         //FIXME: identify assembly names, as extract the name, and try with that?
217                                         AssemblyName aname;
218                                         if (assembly_resolver.TryGetAssemblyNameFromFile (item.ItemSpec, out aname))
219                                                 resolved = assembly_resolver.GetResolvedReference (item, item.ItemSpec, aname, true,
220                                                                 SearchPath.RawFileName);
221                                 } else if (String.Compare (spath, "{CandidateAssemblyFiles}") == 0) {
222                                         assembly_resolver.LogSearchMessage (
223                                                         "Warning: {{CandidateAssemblyFiles}} not supported currently");
224                                 } else if (String.Compare (spath, "{PkgConfig}") == 0) {
225                                         resolved = assembly_resolver.ResolvePkgConfigReference (item, specific_version);
226                                 } else {
227                                         resolved = assembly_resolver.FindInDirectory (
228                                                         item, spath,
229                                                         allowedAssemblyExtensions ?? default_assembly_extensions,
230                                                         specific_version);
231                                 }
232
233                                 if (resolved != null)
234                                         break;
235                         }
236
237                         if (resolved != null && set_copy_local)
238                                 SetCopyLocal (resolved.TaskItem, resolved.CopyLocal.ToString ());
239
240                         return resolved;
241                 }
242
243                 bool TryGetSpecificVersionValue (ITaskItem item, out bool specific_version)
244                 {
245                         specific_version = true;
246                         string value = item.GetMetadata ("SpecificVersion");
247                         if (String.IsNullOrEmpty (value)) {
248                                 //AssemblyName name = new AssemblyName (item.ItemSpec);
249                                 // If SpecificVersion is not specified, then
250                                 // it is true if the Include is a strong name else false
251                                 //specific_version = assembly_resolver.IsStrongNamed (name);
252
253                                 // msbuild seems to just look for a ',' in the name :/
254                                 specific_version = item.ItemSpec.IndexOf (',') >= 0;
255                                 return true;
256                         }
257
258                         if (Boolean.TryParse (value, out specific_version))
259                                 return true;
260
261                         Log.LogError ("Item '{0}' has attribute SpecificVersion with invalid value '{1}' " +
262                                         "which could not be converted to a boolean.", item.ItemSpec, value);
263                         return false;
264                 }
265
266                 //FIXME: Consider CandidateAssemblyFiles also here
267                 void ResolveAssemblyFiles ()
268                 {
269                         if (assemblyFiles == null)
270                                 return;
271
272                         foreach (ITaskItem item in assemblyFiles) {
273                                 assembly_resolver.ResetSearchLogger ();
274
275                                 if (!File.Exists (item.ItemSpec)) {
276                                         LogWithPrecedingNewLine (MessageImportance.Low,
277                                                         "Primary Reference from AssemblyFiles {0}, file not found. Ignoring",
278                                                         item.ItemSpec);
279                                         continue;
280                                 }
281
282                                 LogWithPrecedingNewLine (MessageImportance.Low, "Primary Reference from AssemblyFiles {0}", item.ItemSpec);
283                                 string copy_local;
284
285                                 AssemblyName aname;
286                                 if (!assembly_resolver.TryGetAssemblyNameFromFile (item.ItemSpec, out aname)) {
287                                         Log.LogWarning ("Reference '{0}' not resolved", item.ItemSpec);
288                                         assembly_resolver.LogSearchLoggerMessages (MessageImportance.Normal);
289                                         continue;
290                                 }
291
292                                 if (Environment.GetEnvironmentVariable ("XBUILD_LOG_REFERENCE_RESOLVER") != null)
293                                         assembly_resolver.LogSearchLoggerMessages (MessageImportance.Low);
294
295                                 ResolvedReference rr = assembly_resolver.GetResolvedReference (item, item.ItemSpec, aname, true,
296                                                 SearchPath.RawFileName);
297                                 copy_local = rr.CopyLocal.ToString ();
298
299                                 if (!TryAddNewReference (tempResolvedFiles, rr))
300                                         // already resolved
301                                         continue;
302
303                                 SetCopyLocal (rr.TaskItem, copy_local);
304
305                                 FindAndAddRelatedFiles (item.ItemSpec, copy_local);
306                                 FindAndAddSatellites (item.ItemSpec, copy_local);
307
308                                 if (FindDependencies && !IsFromGacOrTargetFramework (rr) &&
309                                                 rr.FoundInSearchPath != SearchPath.PkgConfig)
310                                         primaryReferences.Add (new PrimaryReference (item, copy_local));
311                         }
312                 }
313
314                 // Tries to resolve assemblies referenced by @item
315                 // Skips gac references
316                 // @item : filename
317                 void ResolveAssemblyFileDependencies (ITaskItem item, string parent_copy_local)
318                 {
319                         Queue<string> dependencies = new Queue<string> ();
320                         dependencies.Enqueue (item.ItemSpec);
321
322                         while (dependencies.Count > 0) {
323                                 string filename = Path.GetFullPath (dependencies.Dequeue ());
324                                 Assembly asm = Assembly.ReflectionOnlyLoadFrom (filename);
325                                 if (alreadyScannedAssemblyNames.ContainsKey (asm.FullName))
326                                         continue;
327
328                                 // set the 1st search path to this ref's base path
329                                 // Will be used for resolving the dependencies
330                                 dependency_search_paths [0] = Path.GetDirectoryName (filename);
331
332                                 foreach (AssemblyName aname in asm.GetReferencedAssemblies ()) {
333                                         if (alreadyScannedAssemblyNames.ContainsKey (aname.FullName))
334                                                 continue;
335
336                                         ResolvedReference resolved_ref = ResolveDependencyByAssemblyName (
337                                                 aname, asm.FullName, parent_copy_local);
338
339                                         if (IncludeDependencies (resolved_ref, aname.FullName)) {
340                                                 tempResolvedDepFiles[resolved_ref.AssemblyName.FullName] = resolved_ref.TaskItem;
341                                                 dependencies.Enqueue (resolved_ref.TaskItem.ItemSpec);
342                                         }
343                                 }
344                                 alreadyScannedAssemblyNames.Add (asm.FullName, String.Empty);
345                         }
346                 }
347
348                 // Resolves by looking dependency_search_paths
349                 // which is dir of parent reference file, and
350                 // SearchPaths
351                 ResolvedReference ResolveDependencyByAssemblyName (AssemblyName aname, string parent_asm_name,
352                                 string parent_copy_local)
353                 {
354                         // This will check for compatible assembly name/version
355                         ResolvedReference resolved_ref;
356                         if (TryGetResolvedReferenceByAssemblyName (aname, false, out resolved_ref))
357                                 return resolved_ref;
358
359                         LogWithPrecedingNewLine (MessageImportance.Low, "Dependency {0}", aname);
360                         Log.LogMessage (MessageImportance.Low, "\tRequired by {0}", parent_asm_name);
361
362                         ITaskItem item = new TaskItem (aname.FullName);
363                         item.SetMetadata ("SpecificVersion", "false");
364                         resolved_ref = ResolveReference (item, dependency_search_paths, false);
365
366                         if (resolved_ref != null) {
367                                 if (Environment.GetEnvironmentVariable ("XBUILD_LOG_REFERENCE_RESOLVER") != null)
368                                                 assembly_resolver.LogSearchLoggerMessages (MessageImportance.Low);
369
370                                 Log.LogMessage (MessageImportance.Low, "\tReference {0} resolved to {1}.",
371                                         aname, resolved_ref.TaskItem.ItemSpec);
372
373                                 Log.LogMessage (MessageImportance.Low,
374                                                 "\tReference found at search path {0}",
375                                                 resolved_ref.FoundInSearchPathAsString);
376
377                                 if (resolved_ref.FoundInSearchPath == SearchPath.Directory) {
378                                         // override CopyLocal with parent's val
379                                         SetCopyLocal (resolved_ref.TaskItem, parent_copy_local);
380
381                                         Log.LogMessage (MessageImportance.Low,
382                                                         "\tThis is CopyLocal {0} as parent item has this value",
383                                                         parent_copy_local);
384
385                                         if (TryAddNewReference (tempResolvedFiles, resolved_ref)) {
386                                                 FindAndAddRelatedFiles (resolved_ref.TaskItem.ItemSpec, parent_copy_local);
387                                                 FindAndAddSatellites (resolved_ref.TaskItem.ItemSpec, parent_copy_local);
388                                         }
389                                 } else {
390                                         //gac or tgtfmwk
391                                         Log.LogMessage (MessageImportance.Low,
392                                                         "\tThis is CopyLocal false as it is in the gac," +
393                                                         "target framework directory or provided by a package.");
394
395                                         TryAddNewReference (tempResolvedFiles, resolved_ref);
396                                 }
397                         } else {
398                                 Log.LogWarning ("Reference '{0}' not resolved", aname);
399                                 assembly_resolver.LogSearchLoggerMessages (MessageImportance.Normal);
400                         }
401
402                         return resolved_ref;
403                 }
404
405                 void FindAndAddRelatedFiles (string filename, string parent_copy_local)
406                 {
407                         if (!findRelatedFiles || allowedRelatedFileExtensions == null)
408                                 return;
409
410                         foreach (string ext in allowedRelatedFileExtensions) {
411                                 string rfile = Path.ChangeExtension (filename, ext);
412                                 if (File.Exists (rfile)) {
413                                         ITaskItem item = new TaskItem (rfile);
414                                         SetCopyLocal (item, parent_copy_local);
415
416                                         tempRelatedFiles.AddUniqueFile (item);
417                                 }
418                         }
419                 }
420
421                 void FindAndAddSatellites (string filename, string parent_copy_local)
422                 {
423                         if (!FindSatellites)
424                                 return;
425
426                         string basepath = Path.GetDirectoryName (filename);
427                         string resource = String.Format ("{0}{1}{2}",
428                                         Path.GetFileNameWithoutExtension (filename),
429                                         ".resources",
430                                         Path.GetExtension (filename));
431
432                         string dir_sep = Path.DirectorySeparatorChar.ToString ();
433                         foreach (string dir in Directory.GetDirectories (basepath)) {
434                                 string culture = Path.GetFileName (dir);
435                                 if (!CultureNamesTable.ContainsKey (culture))
436                                         continue;
437
438                                 string res_path = Path.Combine (dir, resource);
439                                 if (File.Exists (res_path)) {
440                                         ITaskItem item = new TaskItem (res_path);
441                                         SetCopyLocal (item, parent_copy_local);
442                                         item.SetMetadata ("DestinationSubdirectory", culture + dir_sep);
443                                         tempSatelliteFiles.AddUniqueFile (item);
444                                 }
445                         }
446                 }
447
448                 // returns true is it was new
449                 bool TryAddNewReference (List<ITaskItem> file_list, ResolvedReference key_ref)
450                 {
451                         ResolvedReference found_ref;
452                         if (!TryGetResolvedReferenceByAssemblyName (key_ref.AssemblyName, key_ref.IsPrimary, out found_ref)) {
453                                 assemblyNameToResolvedRef [key_ref.AssemblyName.Name] = key_ref;
454                                 file_list.Add (key_ref.TaskItem);
455
456                                 return true;
457                         }
458                         return false;
459                 }
460
461                 void SetCopyLocal (ITaskItem item, string copy_local)
462                 {
463                         item.SetMetadata ("CopyLocal", copy_local);
464
465                         // Assumed to be valid value
466                         if (Boolean.Parse (copy_local))
467                                 tempCopyLocalFiles.AddUniqueFile (item);
468                 }
469
470                 bool TryGetResolvedReferenceByAssemblyName (AssemblyName key_aname, bool is_primary, out ResolvedReference found_ref)
471                 {
472                         found_ref = null;
473                         // Match by just name
474                         if (!assemblyNameToResolvedRef.TryGetValue (key_aname.Name, out found_ref))
475                                 // not there
476                                 return false;
477
478                         // match for full name
479                         if (AssemblyResolver.AssemblyNamesCompatible (key_aname, found_ref.AssemblyName, true, false))
480                                 // exact match, so its already there, dont add anything
481                                 return true;
482
483                         // we have a name match, but version mismatch!
484                         assembly_resolver.LogSearchMessage ("A conflict was detected between '{0}' and '{1}'",
485                                         key_aname.FullName, found_ref.AssemblyName.FullName);
486
487                         if (is_primary == found_ref.IsPrimary) {
488                                 assembly_resolver.LogSearchMessage ("Unable to choose between the two. " +
489                                                 "Choosing '{0}' arbitrarily.", found_ref.AssemblyName.FullName);
490                                 return true;
491                         }
492
493                         // since all dependencies are processed after
494                         // all primary refererences, the one in the cache
495                         // has to be a primary
496                         // Prefer a primary reference over a dependency
497
498                         assembly_resolver.LogSearchMessage ("Choosing '{0}' as it is a primary reference.",
499                                         found_ref.AssemblyName.FullName);
500
501                         // If we can successfully use the primary reference, don't log a warning. It's too
502                         // verbose.
503                         //LogConflictWarning (found_ref.AssemblyName.FullName, key_aname.FullName);
504
505                         return true;
506                 }
507
508                 void LogWithPrecedingNewLine (MessageImportance importance, string format, params object [] args)
509                 {
510                         Log.LogMessage (importance, String.Empty);
511                         Log.LogMessage (importance, format, args);
512                 }
513
514                 // conflict b/w @main and @conflicting, picking @main
515                 void LogConflictWarning (string main, string conflicting)
516                 {
517                         string key = main + ":" + conflicting;
518                         if (!conflictWarningsCache.ContainsKey (key)) {
519                                 Log.LogWarning ("Found a conflict between : '{0}' and '{1}'. Using '{0}' reference.",
520                                                 main, conflicting);
521                                 conflictWarningsCache [key] = key;
522                         }
523                 }
524
525                 bool IsFromGacOrTargetFramework (ResolvedReference rr)
526                 {
527                         return rr.FoundInSearchPath == SearchPath.Gac ||
528                                 rr.FoundInSearchPath == SearchPath.TargetFrameworkDirectory;
529                 }
530
531                 bool IncludeDependencies (ResolvedReference rr, string aname)
532                 {
533                         if (rr == null)
534                                 return false;
535                         if (aname.Equals ("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"))
536                                 return true;
537                         return !IsFromGacOrTargetFramework (rr) && rr.FoundInSearchPath != SearchPath.PkgConfig;
538                 }
539
540                 void LogTaskParameters ()
541                 {
542                         Log.LogMessage (MessageImportance.Low, "TargetFrameworkDirectories:");
543                         if (TargetFrameworkDirectories != null)
544                                 foreach (string dir in TargetFrameworkDirectories)
545                                         Log.LogMessage (MessageImportance.Low, "\t{0}", dir);
546
547                         Log.LogMessage (MessageImportance.Low, "SearchPaths:");
548                         if (SearchPaths != null)
549                                 foreach (string path in SearchPaths)
550                                         Log.LogMessage (MessageImportance.Low, "\t{0}", path);
551                 }
552
553                 public bool AutoUnify {
554                         get { return autoUnify; }
555                         set { autoUnify = value; }
556                 }
557                 
558                 public ITaskItem[] AssemblyFiles {
559                         get { return assemblyFiles; }
560                         set { assemblyFiles = value; }
561                 }
562                 
563                 public ITaskItem[] Assemblies {
564                         get { return assemblies; }
565                         set { assemblies = value; }
566                 }
567                 
568                 public string AppConfigFile {
569                         get { return appConfigFile; }
570                         set { appConfigFile = value; }
571                 }
572                 
573                 public string[] AllowedAssemblyExtensions {
574                         get { return allowedAssemblyExtensions; }
575                         set { allowedAssemblyExtensions = value; }
576                 }
577
578                 public string[] AllowedRelatedFileExtensions {
579                         get { return allowedRelatedFileExtensions; }
580                         set { allowedRelatedFileExtensions = value; }
581                 }
582                 
583                 public string[] CandidateAssemblyFiles {
584                         get { return candidateAssemblyFiles; }
585                         set { candidateAssemblyFiles = value; }
586                 }
587                 
588                 [Output]
589                 public ITaskItem[] CopyLocalFiles {
590                         get { return copyLocalFiles; }
591                 }
592                 
593                 [Output]
594                 public ITaskItem[] FilesWritten {
595                         get { return filesWritten; }
596                         set { filesWritten = value; }
597                 }
598                 
599                 public bool FindDependencies {
600                         get { return findDependencies; }
601                         set { findDependencies = value; }
602                 }
603                 
604                 public bool FindRelatedFiles {
605                         get { return findRelatedFiles; }
606                         set { findRelatedFiles = value; }
607                 }
608                 
609                 public bool FindSatellites {
610                         get { return findSatellites; }
611                         set { findSatellites = value; }
612                 }
613                 
614                 public bool FindSerializationAssemblies {
615                         get { return findSerializationAssemblies; }
616                         set { findSerializationAssemblies = value; }
617                 }
618                 
619                 public string[] InstalledAssemblyTables {
620                         get { return installedAssemblyTables; }
621                         set { installedAssemblyTables = value; }
622                 }
623                 
624                 [Output]
625                 public ITaskItem[] RelatedFiles {
626                         get { return relatedFiles; }
627                 }
628                 
629                 [Output]
630                 public ITaskItem[] ResolvedDependencyFiles {
631                         get { return resolvedDependencyFiles; }
632                 }
633                 
634                 [Output]
635                 public ITaskItem[] ResolvedFiles {
636                         get { return resolvedFiles; }
637                 }
638                 
639                 [Output]
640                 public ITaskItem[] SatelliteFiles {
641                         get { return satelliteFiles; }
642                 }
643                 
644                 [Output]
645                 public ITaskItem[] ScatterFiles {
646                         get { return scatterFiles; }
647                 }
648                 
649                 [Required]
650                 public string[] SearchPaths {
651                         get { return searchPaths; }
652                         set { searchPaths = value; }
653                 }
654                 
655                 [Output]
656                 public ITaskItem[] SerializationAssemblyFiles {
657                         get { return serializationAssemblyFiles; }
658                 }
659                 
660                 public bool Silent {
661                         get { return silent; }
662                         set { silent = value; }
663                 }
664                 
665                 public string StateFile {
666                         get { return stateFile; }
667                         set { stateFile = value; }
668                 }
669                 
670                 [Output]
671                 public ITaskItem[] SuggestedRedirects {
672                         get { return suggestedRedirects; }
673                 }
674
675 #if NET_4_0
676                 public string TargetFrameworkMoniker { get; set; }
677
678                 public string TargetFrameworkMonikerDisplayName { get; set; }
679 #endif
680
681                 public string TargetFrameworkVersion { get; set; }
682
683                 public string[] TargetFrameworkDirectories {
684                         get { return targetFrameworkDirectories; }
685                         set { targetFrameworkDirectories = value; }
686                 }
687                 
688                 public string TargetProcessorArchitecture {
689                         get { return targetProcessorArchitecture; }
690                         set { targetProcessorArchitecture = value; }
691                 }
692
693
694                 static Dictionary<string, string> cultureNamesTable;
695                 static Dictionary<string, string> CultureNamesTable {
696                         get {
697                                 if (cultureNamesTable == null) {
698                                         cultureNamesTable = new Dictionary<string, string> ();
699                                         foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures))
700                                                 cultureNamesTable [ci.Name] = ci.Name;
701                                 }
702
703                                 return cultureNamesTable;
704                         }
705                 }
706         }
707
708         static class ResolveAssemblyReferenceHelper {
709                 public static void AddUniqueFile (this Dictionary<string, ITaskItem> dic, ITaskItem item)
710                 {
711                         if (dic == null)
712                                 throw new ArgumentNullException ("dic");
713                         if (item == null)
714                                 throw new ArgumentNullException ("item");
715
716                         string fullpath = Path.GetFullPath (item.ItemSpec);
717                         if (!dic.ContainsKey (fullpath))
718                                 dic [fullpath] = item;
719                 }
720         }
721
722         struct PrimaryReference {
723                 public ITaskItem TaskItem;
724                 public string ParentCopyLocal;
725
726                 public PrimaryReference (ITaskItem item, string parent_copy_local)
727                 {
728                         TaskItem = item;
729                         ParentCopyLocal = parent_copy_local;
730                 }
731         }
732
733 }
734
735 #endif