2007-01-29 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 ("Reference {0} resolved to {1}", item.ItemSpec, resolved);
84                                         tempResolvedFiles.Add (new TaskItem (resolved));
85                         }
86                         
87                         resolvedFiles = tempResolvedFiles.ToArray ();
88
89                         return true;
90                 }
91                 
92                 public bool AutoUnify {
93                         get { return autoUnify; }
94                         set { autoUnify = value; }
95                 }
96                 
97                 public ITaskItem[] AssemblyFiles {
98                         get { return assemblyFiles; }
99                         set { assemblyFiles = value; }
100                 }
101                 
102                 public ITaskItem[] Assemblies {
103                         get { return assemblies; }
104                         set { assemblies = value; }
105                 }
106                 
107                 public string AppConfigFile {
108                         get { return appConfigFile; }
109                         set { appConfigFile = value; }
110                 }
111                 
112                 public string[] AllowedAssemblyExtensions {
113                         get { return allowedAssemblyExtensions; }
114                         set { allowedAssemblyExtensions = value; }
115                 }
116                 
117                 public string[] CandidateAssemblyFiles {
118                         get { return candidateAssemblyFiles; }
119                         set { candidateAssemblyFiles = value; }
120                 }
121                 
122                 [Output]
123                 public ITaskItem[] CopyLocalFiles {
124                         get { return copyLocalFiles; }
125                 }
126                 
127                 [Output]
128                 public ITaskItem[] FilesWritten {
129                         get { return filesWritten; }
130                         set { filesWritten = value; }
131                 }
132                 
133                 public bool FindDependencies {
134                         get { return findDependencies; }
135                         set { findDependencies = value; }
136                 }
137                 
138                 public bool FindRelatedFiles {
139                         get { return findRelatedFiles; }
140                         set { findRelatedFiles = value; }
141                 }
142                 
143                 public bool FindSatellites {
144                         get { return findSatellites; }
145                         set { findSatellites = value; }
146                 }
147                 
148                 public bool FindSerializationAssemblies {
149                         get { return findSerializationAssemblies; }
150                         set { findSerializationAssemblies = value; }
151                 }
152                 
153                 public string[] InstalledAssemblyTables {
154                         get { return installedAssemblyTables; }
155                         set { installedAssemblyTables = value; }
156                 }
157                 
158                 [Output]
159                 public ITaskItem[] RelatedFiles {
160                         get { return relatedFiles; }
161                 }
162                 
163                 [Output]
164                 public ITaskItem[] ResolvedDependencyFiles {
165                         get { return resolvedDependencyFiles; }
166                 }
167                 
168                 [Output]
169                 public ITaskItem[] ResolvedFiles {
170                         get { return resolvedFiles; }
171                 }
172                 
173                 [Output]
174                 public ITaskItem[] SatelliteFiles {
175                         get { return satelliteFiles; }
176                 }
177                 
178                 [Output]
179                 public ITaskItem[] ScatterFiles {
180                         get { return scatterFiles; }
181                 }
182                 
183                 [Required]
184                 public string[] SearchPaths {
185                         get { return searchPaths; }
186                         set { searchPaths = value; }
187                 }
188                 
189                 [Output]
190                 public ITaskItem[] SerializationAssemblyFiles {
191                         get { return serializationAssemblyFiles; }
192                 }
193                 
194                 public bool Silent {
195                         get { return silent; }
196                         set { silent = value; }
197                 }
198                 
199                 public string StateFile {
200                         get { return stateFile; }
201                         set { stateFile = value; }
202                 }
203                 
204                 [Output]
205                 public ITaskItem[] SuggestedRedirects {
206                         get { return suggestedRedirects; }
207                 }
208                 
209                 public string[] TargetFrameworkDirectories {
210                         get { return targetFrameworkDirectories; }
211                         set { targetFrameworkDirectories = value; }
212                 }
213                 
214                 public string TargetProcessorArchitecture {
215                         get { return targetProcessorArchitecture; }
216                         set { targetProcessorArchitecture = value; }
217                 }
218         }
219 }
220
221 #endif