5 // Leszek Ciesielski <skolima@gmail.com>
6 // Marek Sieradzki <marek.sieradzki@gmail.com>
8 // Copyright (C) 2006 Forcom (http://www.forcom.com.pl/)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using Microsoft.Build.Framework;
36 using Microsoft.Build.Utilities;
38 namespace Microsoft.Build.Tasks {
40 public class Vbc : ManagedCompiler {
47 protected internal override void AddResponseFileCommands (
48 CommandLineBuilderExtension commandLine )
50 base.AddResponseFileCommands (commandLine);
52 commandLine.AppendSwitchIfNotNull ("/libpath:", AdditionalLibPaths, ",");
54 commandLine.AppendSwitchIfNotNull ("/baseaddress:", BaseAddress);
56 if (DefineConstants != null)
57 commandLine.AppendSwitchUnquotedIfNotNull ("/define:",
58 String.Format ("\"{0}\"", EscapeDoubleQuotes (DefineConstants)));
62 commandLine.AppendSwitchIfNotNull ("/doc:", DocumentationFile);
66 // GenerateDocumentation
69 foreach (ITaskItem item in Imports)
70 commandLine.AppendSwitchIfNotNull ("/imports:", item.ItemSpec);
72 commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);
77 commandLine.AppendSwitch ("/nowarn");
79 commandLine.AppendSwitchIfNotNull ("/optioncompare:", OptionCompare);
81 if (Bag ["OptionExplicit"] != null)
83 commandLine.AppendSwitch ("/optionexplicit+");
85 commandLine.AppendSwitch ("/optionexplicit-");
87 if (Bag ["OptionStrict"] != null)
89 commandLine.AppendSwitch ("/optionstrict+");
91 commandLine.AppendSwitch ("/optionstrict-");
97 if (References != null)
98 foreach (ITaskItem item in References)
99 commandLine.AppendSwitchIfNotNull ("/reference:", item.ItemSpec);
101 if (Bag ["RemoveIntegerChecks"] != null)
102 if (RemoveIntegerChecks)
103 commandLine.AppendSwitch ("/removeintchecks+");
105 commandLine.AppendSwitch ("/removeintchecks-");
107 if (ResponseFiles != null)
108 foreach (ITaskItem item in ResponseFiles)
109 commandLine.AppendFileNameIfNotNull (String.Format ("@{0}", item.ItemSpec));
111 commandLine.AppendSwitchIfNotNull ("/rootnamespace:", RootNamespace);
113 commandLine.AppendSwitchIfNotNull ("/sdkpath:", SdkPath);
115 // TargetCompactFramework
121 // WarningsNotAsErrors
125 string EscapeDoubleQuotes (string text)
130 return text.Replace ("\"", "\\\"");
134 protected override bool CallHostObjectToExecute ()
136 throw new NotImplementedException ();
140 protected override string GenerateFullPathToTool ()
142 return Path.Combine (ToolPath, ToolExe);
146 protected override HostObjectInitializationStatus InitializeHostObject ()
148 throw new NotImplementedException ();
152 protected override bool ValidateParameters ()
154 throw new NotImplementedException ();
158 public string BaseAddress {
159 get { return (string) Bag ["BaseAddress"]; }
160 set { Bag ["BaseAddress"] = value; }
164 public string DisabledWarnings {
165 get { return (string) Bag ["DisabledWarnings"]; }
166 set { Bag ["DisabledWarnings"] = value; }
170 public string DocumentationFile {
171 get { return (string) Bag ["DocumentationFile"]; }
172 set { Bag ["DocumentationFile"] = value; }
176 public string ErrorReport {
177 get { return (string) Bag ["ErrorReport"]; }
178 set { Bag ["ErrorReport"] = value; }
182 public bool GenerateDocumentation {
183 get { return GetBoolParameterWithDefault ("GenerateDocumentation", false); }
184 set { Bag ["GenerateDocumentation"] = value; }
188 public ITaskItem [] Imports {
189 get { return (ITaskItem []) Bag ["Imports"]; }
190 set { Bag ["Imports"] = value; }
194 public bool NoStandardLib {
195 get { return GetBoolParameterWithDefault ("NoStandardLib", false); }
196 set { Bag ["NoStandardLib"] = value; }
200 public bool NoWarnings {
201 get { return GetBoolParameterWithDefault ("NoWarnings", false); }
202 set { Bag ["NoWarnings"] = value; }
206 public string OptionCompare {
207 get { return (string) Bag ["OptionCompare"]; }
208 set { Bag ["OptionCompare"] = value; }
212 public bool OptionExplicit {
213 get { return GetBoolParameterWithDefault ("OptionExplicit", false); }
214 set { Bag ["OpExplicit"] = value; }
218 public bool OptionStrict {
219 get { return GetBoolParameterWithDefault ("OptionStrict", false); }
220 set { Bag ["OptionStrict"] = value; }
224 public string OptionStrictType {
225 get { return (string) Bag ["OptionStrictType"]; }
226 set { Bag ["OptionStrictType"] = value; }
230 public string Platform {
231 get { return (string) Bag ["Platfrom"]; }
232 set { Bag ["Platform"] = value; }
236 public bool RemoveIntegerChecks {
237 get { return GetBoolParameterWithDefault ("RemoveIntegerChecks", false); }
238 set { Bag ["RemoveIntegerChecks"] = value; }
242 public string RootNamespace {
243 get { return (string) Bag ["RootNamespace"]; }
244 set { Bag ["RootNamespace"] = value; }
248 public string SdkPath {
249 get { return (string) Bag ["SdkPath"]; }
250 set { Bag ["SdkPath"] = value; }
254 public bool TargetCompactFramework {
255 get { return (bool) Bag ["TargetCompactFramework"]; }
256 set { Bag ["TargetCompactFramework"] = value; }
260 protected override string ToolName {
261 get { return Utilities.RunningOnWindows ? "vbnc.bat" : "vbnc"; }
265 public bool UseHostCompilerIfAvailable {
266 get { return (bool) Bag ["UseHostCompilerIfAvailable"]; }
267 set { Bag ["UseHostCompilerIfAvailable"] = value; }
271 public string Verbosity {
272 get { return (string) Bag ["Verbosity"]; }
273 set { Bag ["Verbosity"] = value; }
277 public string WarningsAsErrors {
278 get { return (string) Bag ["WarningsAsErrors"]; }
279 set { Bag ["WarningsAsErrors"] = value; }
283 public string WarningsNotAsErrors {
284 get { return (string) Bag ["WarningsNotAsErrors"]; }
285 set { Bag ["WarningsNotAsErrors"] = value; }