2007-02-02 Marek Sieradzki <marek.sieradzki@gmail.com>
[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 // 
7 // (C) 2006 Marek Sieradzki
8 //
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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.
27
28 #if NET_2_0
29
30 using System;
31 using System.Collections.Generic;
32 using System.IO;
33 using System.Security;
34 using Microsoft.Build.Framework;
35 using Microsoft.Build.Utilities;
36
37 namespace Microsoft.Build.Tasks {
38         public class ResolveAssemblyReference : TaskExtension {
39         
40                 bool            autoUnify;
41                 ITaskItem[]     assemblyFiles;
42                 ITaskItem[]     assemblies;
43                 string          appConfigFile;
44                 string[]        allowedAssemblyExtensions;
45                 string[]        candidateAssemblyFiles;
46                 ITaskItem[]     copyLocalFiles;
47                 ITaskItem[]     filesWritten;
48                 bool            findDependencies;
49                 bool            findRelatedFiles;
50                 bool            findSatellites;
51                 bool            findSerializationAssemblies;
52                 string[]        installedAssemblyTables;
53                 ITaskItem[]     relatedFiles;
54                 ITaskItem[]     resolvedDependencyFiles;
55                 ITaskItem[]     resolvedFiles;
56                 ITaskItem[]     satelliteFiles;
57                 ITaskItem[]     scatterFiles;
58                 string[]        searchPaths;
59                 ITaskItem[]     serializationAssemblyFiles;
60                 bool            silent;
61                 string          stateFile;
62                 ITaskItem[]     suggestedRedirects;
63                 string[]        targetFrameworkDirectories;
64                 string          targetProcessorArchitecture;
65
66                 AssemblyResolver        assembly_resolver;
67
68                 public ResolveAssemblyReference ()
69                 {
70                         assembly_resolver = new AssemblyResolver ();
71                 }
72
73                 public override bool Execute ()
74                 {
75                         List <ITaskItem> tempResolvedFiles = new List <ITaskItem> ();
76                 
77                         foreach (ITaskItem item in assemblies) {
78                                 string resolved = assembly_resolver.ResolveAssemblyReference (item);
79
80                                 if (resolved == null) {
81                                         Log.LogWarning ("Reference {0} not resolved", item.ItemSpec);
82                                 } else {
83                                         Log.LogMessage (MessageImportance.Low, "Reference {0} resolved to {1}", item.ItemSpec, resolved);
84                                         tempResolvedFiles.Add (new TaskItem (resolved));
85                                 }
86                         }
87                         
88                         resolvedFiles = tempResolvedFiles.ToArray ();
89
90                         return true;
91                 }
92                 
93                 public bool AutoUnify {
94                         get { return autoUnify; }
95                         set { autoUnify = value; }
96                 }
97                 
98                 public ITaskItem[] AssemblyFiles {
99                         get { return assemblyFiles; }
100                         set { assemblyFiles = value; }
101                 }
102                 
103                 public ITaskItem[] Assemblies {
104                         get { return assemblies; }
105                         set { assemblies = value; }
106                 }
107                 
108                 public string AppConfigFile {
109                         get { return appConfigFile; }
110                         set { appConfigFile = value; }
111                 }
112                 
113                 public string[] AllowedAssemblyExtensions {
114                         get { return allowedAssemblyExtensions; }
115                         set { allowedAssemblyExtensions = value; }
116                 }
117                 
118                 public string[] CandidateAssemblyFiles {
119                         get { return candidateAssemblyFiles; }
120                         set { candidateAssemblyFiles = value; }
121                 }
122                 
123                 [Output]
124                 public ITaskItem[] CopyLocalFiles {
125                         get { return copyLocalFiles; }
126                 }
127                 
128                 [Output]
129                 public ITaskItem[] FilesWritten {
130                         get { return filesWritten; }
131                         set { filesWritten = value; }
132                 }
133                 
134                 public bool FindDependencies {
135                         get { return findDependencies; }
136                         set { findDependencies = value; }
137                 }
138                 
139                 public bool FindRelatedFiles {
140                         get { return findRelatedFiles; }
141                         set { findRelatedFiles = value; }
142                 }
143                 
144                 public bool FindSatellites {
145                         get { return findSatellites; }
146                         set { findSatellites = value; }
147                 }
148                 
149                 public bool FindSerializationAssemblies {
150                         get { return findSerializationAssemblies; }
151                         set { findSerializationAssemblies = value; }
152                 }
153                 
154                 public string[] InstalledAssemblyTables {
155                         get { return installedAssemblyTables; }
156                         set { installedAssemblyTables = value; }
157                 }
158                 
159                 [Output]
160                 public ITaskItem[] RelatedFiles {
161                         get { return relatedFiles; }
162                 }
163                 
164                 [Output]
165                 public ITaskItem[] ResolvedDependencyFiles {
166                         get { return resolvedDependencyFiles; }
167                 }
168                 
169                 [Output]
170                 public ITaskItem[] ResolvedFiles {
171                         get { return resolvedFiles; }
172                 }
173                 
174                 [Output]
175                 public ITaskItem[] SatelliteFiles {
176                         get { return satelliteFiles; }
177                 }
178                 
179                 [Output]
180                 public ITaskItem[] ScatterFiles {
181                         get { return scatterFiles; }
182                 }
183                 
184                 [Required]
185                 public string[] SearchPaths {
186                         get { return searchPaths; }
187                         set { searchPaths = value; }
188                 }
189                 
190                 [Output]
191                 public ITaskItem[] SerializationAssemblyFiles {
192                         get { return serializationAssemblyFiles; }
193                 }
194                 
195                 public bool Silent {
196                         get { return silent; }
197                         set { silent = value; }
198                 }
199                 
200                 public string StateFile {
201                         get { return stateFile; }
202                         set { stateFile = value; }
203                 }
204                 
205                 [Output]
206                 public ITaskItem[] SuggestedRedirects {
207                         get { return suggestedRedirects; }
208                 }
209                 
210                 public string[] TargetFrameworkDirectories {
211                         get { return targetFrameworkDirectories; }
212                         set { targetFrameworkDirectories = value; }
213                 }
214                 
215                 public string TargetProcessorArchitecture {
216                         get { return targetProcessorArchitecture; }
217                         set { targetProcessorArchitecture = value; }
218                 }
219         }
220 }
221
222 #endif