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