New 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 // 
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                 public ResolveAssemblyReference ()
67                 {
68                 }
69
70                 // FIXME: very primitive version that references <reference>.dll or uses
71                 // HintPath if it's there
72                 
73                 public override bool Execute ()
74                 {
75                         List <ITaskItem> tempResolvedFiles = new List <ITaskItem> ();
76                 
77                         foreach (ITaskItem item in assemblies) {
78                                 if (item.GetMetadata ("HintPath") != String.Empty)
79                                         tempResolvedFiles.Add (new TaskItem (item.GetMetadata ("HintPath")));
80                                 else
81                                         tempResolvedFiles.Add (new TaskItem (String.Format ("{0}.dll",item.ItemSpec)));
82                         }
83                         
84                         resolvedFiles = tempResolvedFiles.ToArray ();
85                         
86                         return true;
87                 }
88                 
89                 public bool AutoUnify {
90                         get { return autoUnify; }
91                         set { autoUnify = value; }
92                 }
93                 
94                 public ITaskItem[] AssemblyFiles {
95                         get { return assemblyFiles; }
96                         set { assemblyFiles = value; }
97                 }
98                 
99                 public ITaskItem[] Assemblies {
100                         get { return assemblies; }
101                         set { assemblies = value; }
102                 }
103                 
104                 public string AppConfigFile {
105                         get { return appConfigFile; }
106                         set { appConfigFile = value; }
107                 }
108                 
109                 public string[] AllowedAssemblyExtensions {
110                         get { return allowedAssemblyExtensions; }
111                         set { allowedAssemblyExtensions = value; }
112                 }
113                 
114                 public string[] CandidateAssemblyFiles {
115                         get { return candidateAssemblyFiles; }
116                         set { candidateAssemblyFiles = value; }
117                 }
118                 
119                 public ITaskItem[] CopyLocalFiles {
120                         get { return copyLocalFiles; }
121                 }
122                 
123                 public ITaskItem[] FilesWritten {
124                         get { return filesWritten; }
125                         set { filesWritten = value; }
126                 }
127                 
128                 public bool FindDependencies {
129                         get { return findDependencies; }
130                         set { findDependencies = value; }
131                 }
132                 
133                 public bool FindRelatedFiles {
134                         get { return findRelatedFiles; }
135                         set { findRelatedFiles = value; }
136                 }
137                 
138                 public bool FindSatellites {
139                         get { return findSatellites; }
140                         set { findSatellites = value; }
141                 }
142                 
143                 public bool FindSerializationAssemblies {
144                         get { return findSerializationAssemblies; }
145                         set { findSerializationAssemblies = value; }
146                 }
147                 
148                 public string[] InstalledAssemblyTables {
149                         get { return installedAssemblyTables; }
150                         set { installedAssemblyTables = value; }
151                 }
152                 
153                 public ITaskItem[] RelatedFiles {
154                         get { return relatedFiles; }
155                         set { relatedFiles = value; }
156                 }
157                 
158                 public ITaskItem[] ResolvedDependencyFiles {
159                         get { return resolvedDependencyFiles; }
160                         set { resolvedDependencyFiles = value; }
161                 }
162                 
163                 [Output]
164                 public ITaskItem[] ResolvedFiles {
165                         get { return resolvedFiles; }
166                         set { resolvedFiles = value; }
167                 }
168                 
169                 public ITaskItem[] SatelliteFiles {
170                         get { return satelliteFiles; }
171                         set { satelliteFiles = value; }
172                 }
173                 
174                 public ITaskItem[] ScatterFiles {
175                         get { return scatterFiles; }
176                 }
177                 
178                 public string[] SearchPaths {
179                         get { return searchPaths; }
180                         set { searchPaths = value; }
181                 }
182                 
183                 public ITaskItem[] SerializationAssemblyFiles {
184                         get { return serializationAssemblyFiles; }
185                 }
186                 
187                 public bool Silent {
188                         get { return silent; }
189                         set { silent = value; }
190                 }
191                 
192                 public string StateFile {
193                         get { return stateFile; }
194                         set { stateFile = value; }
195                 }
196                 
197                 public ITaskItem[] SuggestedRedirects {
198                         get { return suggestedRedirects; }
199                         set { suggestedRedirects = value; }
200                 }
201                 
202                 public string[] TargetFrameworkDirectories {
203                         get { return targetFrameworkDirectories; }
204                         set { targetFrameworkDirectories = value; }
205                 }
206                 
207                 public string TargetProcessorArchitecture {
208                         get { return targetProcessorArchitecture; }
209                         set { targetProcessorArchitecture = value; }
210                 }
211         }
212 }
213
214 #endif