[bcl] Remove NET_2_0 defines from the class libs. This has been done using: unifdef...
[mono.git] / mcs / class / Microsoft.Build.Tasks / Microsoft.Build.Tasks / AL.cs
1 //
2 // AL.cs: Task for assembly linker
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2005 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
29 using System;
30 using System.Diagnostics;
31 using System.IO;
32 using Microsoft.Build.Framework;
33 using Microsoft.Build.Utilities;
34 using Mono.XBuild.Utilities;
35
36 namespace Microsoft.Build.Tasks {
37         public class AL : ToolTaskExtension {
38         
39                 public AL ()
40                 {
41                 }
42                 
43                 [MonoTODO]
44                 protected internal override void AddResponseFileCommands (
45                                                  CommandLineBuilderExtension commandLine)
46                 {
47                         commandLine.AppendSwitchIfNotNull ("/algid:", AlgorithmId);
48                         commandLine.AppendSwitchIfNotNull ("/baseaddress:", BaseAddress);
49                         commandLine.AppendSwitchIfNotNull ("/company:", CompanyName);
50                         commandLine.AppendSwitchIfNotNull ("/configuration:", Configuration);
51                         commandLine.AppendSwitchIfNotNull ("/culture:", Culture);
52                         commandLine.AppendSwitchIfNotNull ("/copyright:", Copyright);
53                         if (Bag ["DelaySign"] != null)
54                                 if (DelaySign)
55                                         commandLine.AppendSwitch ("/delaysign+");
56                                 else
57                                         commandLine.AppendSwitch ("/delaysign-");
58                         commandLine.AppendSwitchIfNotNull ("/description:", Description);
59                         if (EmbedResources != null) {
60                                 foreach (ITaskItem item in EmbedResources) {
61                                         string logical_name = item.GetMetadata ("LogicalName");
62                                         if (!string.IsNullOrEmpty (logical_name))
63                                                 commandLine.AppendSwitchIfNotNull ("/embed:", string.Format ("{0},{1}", item.ItemSpec, logical_name));
64                                         else
65                                                 commandLine.AppendSwitchIfNotNull ("/embed:", item.ItemSpec);
66                                 }
67                         }
68                         commandLine.AppendSwitchIfNotNull ("/evidence:", EvidenceFile);
69                         commandLine.AppendSwitchIfNotNull ("/fileversion:", FileVersion);
70                         commandLine.AppendSwitchIfNotNull ("/flags:", Flags);
71                         if (GenerateFullPaths)
72                                 commandLine.AppendSwitch ("/fullpaths");
73                         commandLine.AppendSwitchIfNotNull ("/keyname:", KeyContainer);
74                         commandLine.AppendSwitchIfNotNull ("/keyfile:", KeyFile);
75                         if (LinkResources != null)
76                                 foreach (ITaskItem item in LinkResources)
77                                         commandLine.AppendSwitchIfNotNull ("/link:", item.ItemSpec);
78                         commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);
79                         if (OutputAssembly != null)
80                                 commandLine.AppendSwitchIfNotNull ("/out:", OutputAssembly.ItemSpec);
81                         //platform
82                         commandLine.AppendSwitchIfNotNull ("/product:", ProductName);
83                         commandLine.AppendSwitchIfNotNull ("/productversion:", ProductVersion);
84                         if (ResponseFiles != null)
85                                 foreach (string s in ResponseFiles)
86                                         commandLine.AppendFileNameIfNotNull (String.Format ("@{0}", s));
87                         if (SourceModules != null)
88                                 foreach (ITaskItem item in SourceModules)
89                                         commandLine.AppendFileNameIfNotNull (item.ItemSpec);
90                         commandLine.AppendSwitchIfNotNull ("/target:", TargetType);
91                         commandLine.AppendSwitchIfNotNull ("/template:", TemplateFile);
92                         commandLine.AppendSwitchIfNotNull ("/title:", Title);
93                         commandLine.AppendSwitchIfNotNull ("/trademark:", Trademark);
94                         commandLine.AppendSwitchIfNotNull ("/version:", Version);
95                         commandLine.AppendSwitchIfNotNull ("/win32icon:", Win32Icon);
96                         commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource);
97                 }
98                 
99                 public override bool Execute ()
100                 {
101                         return base.Execute ();
102                 }
103
104                 protected override string GenerateFullPathToTool ()
105                 {
106                         if (!string.IsNullOrEmpty (ToolPath))
107                                 return Path.Combine (ToolPath, ToolExe);
108                         return ToolLocationHelper.GetPathToDotNetFrameworkFile (ToolExe, TargetDotNetFrameworkVersion.VersionLatest);
109                 }
110
111                 public string AlgorithmId {
112                         get { return (string) Bag ["AlgorithmId"]; }
113                         set { Bag ["AlgorithmId"] = value; }
114                 }
115
116                 public string BaseAddress {
117                         get { return (string) Bag ["BaseAddress"]; }
118                         set { Bag ["BaseAddress"] = value; }
119                 }
120
121                 public string CompanyName {
122                         get { return (string) Bag ["CompanyName"]; }
123                         set { Bag ["CompanyName"] = value; }
124                 }
125
126                 public string Configuration {
127                         get { return (string) Bag ["Configuration"]; }
128                         set { Bag ["Configuration"] = value; }
129                 }
130
131                 public string Copyright {
132                         get { return (string) Bag ["Copyright"]; }
133                         set { Bag ["Copyright"] = value; }
134                 }
135
136                 public string Culture {
137                         get { return (string) Bag ["Culture"]; }
138                         set { Bag ["Culture"] = value; }
139                 }
140
141                 public bool DelaySign {
142                         get { return GetBoolParameterWithDefault ("DelaySign", false); }
143                         set { Bag ["DelaySign"] = value; }
144                 }
145
146                 public string Description {
147                         get { return (string) Bag ["Description"]; }
148                         set { Bag ["Description"] = value; }
149                 }
150
151                 public ITaskItem[] EmbedResources {
152                         get { return (ITaskItem[]) Bag ["EmbedResources"]; }
153                         set { Bag ["EmbedResources"] = value; }
154                 }
155
156                 public string EvidenceFile {
157                         get { return (string) Bag ["EvidenceFile"]; }
158                         set { Bag ["EvidenceFile"] = value; }
159                 }
160
161                 public string FileVersion {
162                         get { return (string) Bag ["FileVersion"]; }
163                         set { Bag ["FileVersion"] = value; }
164                 }
165
166                 public string Flags {
167                         get { return (string) Bag ["Flags"]; }
168                         set { Bag ["Flags"] = value; }
169                 }
170
171                 public bool GenerateFullPaths {
172                         get { return GetBoolParameterWithDefault ("GenerateFullPaths", false); }
173                         set { Bag ["GenerateFullPaths"] = value; }
174                 }
175
176                 public string KeyContainer {
177                         get { return (string) Bag ["KeyContainer"]; }
178                         set { Bag ["KeyContainer"] = value; }
179                 }
180
181                 public string KeyFile {
182                         get { return (string) Bag ["KeyFile"]; }
183                         set { Bag ["KeyFile"] = value; }
184                 }
185
186                 public ITaskItem[] LinkResources {
187                         get { return (ITaskItem[]) Bag ["LinkResources"]; }
188                         set { Bag ["LinkResources"] = value; }
189                 }
190
191                 public string MainEntryPoint {
192                         get { return (string) Bag ["MainEntryPoint"]; }
193                         set { Bag ["MainEntryPoint"] = value; }
194                 }
195
196                 [Required]
197                 [Output]
198                 public ITaskItem OutputAssembly {
199                         get { return (ITaskItem) Bag ["OutputAssembly"]; }
200                         set { Bag ["OutputAssembly"] = value; }
201                 }
202
203                 public string Platform {
204                         get { return (string) Bag ["Platform"]; }
205                         set { Bag ["Platform"] = value; }
206                 }
207
208                 public string ProductName {
209                         get { return (string) Bag ["ProductName"]; }
210                         set { Bag ["ProductName"] = value; }
211                 }
212
213                 public string ProductVersion {
214                         get { return (string) Bag ["ProductVersion"]; }
215                         set { Bag ["ProductVersion"] = value; }
216                 }
217
218                 public string[] ResponseFiles {
219                         get { return (string[]) Bag ["ResponseFiles"]; }
220                         set { Bag ["ResponseFiles"] = value; }
221                 }
222
223                 public ITaskItem[] SourceModules {
224                         get { return (ITaskItem[]) Bag ["SourceModules"]; }
225                         set { Bag ["SourceModules"] = value; }
226                 }
227
228                 public string TargetType {
229                         get { return (string) Bag ["TargetType"]; }
230                         set { Bag ["TargetType"] = value; }
231                 }
232
233                 public string TemplateFile {
234                         get { return (string) Bag ["TemplateFile"]; }
235                         set { Bag ["TemplateFile"] = value; }
236                 }
237
238                 public string Title {
239                         get { return (string) Bag ["Title"]; }
240                         set { Bag ["Title"] = value; }
241                 }
242
243                 protected override string ToolName {
244                         get { return "al.exe"; }
245                 }
246
247                 public string Trademark {
248                         get { return (string) Bag ["Trademark"]; }
249                         set { Bag ["Trademark"] = value; }
250                 }
251
252                 public string Version {
253                         get { return (string) Bag ["Version"]; }
254                         set { Bag ["Version"] = value; }
255                 }
256
257                 public string Win32Icon {
258                         get { return (string) Bag ["Win32Icon"]; }
259                         set { Bag ["Win32Icon"] = value; }
260                 }
261
262                 public string Win32Resource {
263                         get { return (string) Bag ["Win32Resource"]; }
264                         set { Bag ["Win32Resource"] = value; }
265                 }
266         }
267 }
268