// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#if NET_2_0
using System;
using System.Collections;
+using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
namespace Microsoft.Build.Tasks {
public abstract class ManagedCompiler : ToolTaskExtension {
protected internal override void AddResponseFileCommands (
CommandLineBuilderExtension commandLine)
{
- commandLine.AppendSwitchIfNotNull ("/lib:", AdditionalLibPaths, ",");
- commandLine.AppendSwitchIfNotNull ("/addmodule:", AddModules, ",");
+ if (AddModules != null && AddModules.Length > 0)
+ commandLine.AppendSwitchIfNotNull ("/addmodule:", AddModules, ",");
if (Bag ["CodePage"] != null)
commandLine.AppendSwitchIfNotNull ("/codepage:", CodePage.ToString ());
- commandLine.AppendSwitchIfNotNull ("/debug:", DebugType);
- commandLine.AppendSwitchIfNotNull ("/define:", DefineConstants);
+
+ var dtype = DebugType;
+ if (string.Equals (dtype, "full", StringComparison.OrdinalIgnoreCase) || string.Equals (dtype, "pdbonly", StringComparison.OrdinalIgnoreCase))
+ dtype = "portable";
+
+ commandLine.AppendSwitchIfNotNull ("/debug:", dtype);
+
if (Bag ["DelaySign"] != null)
if (DelaySign)
commandLine.AppendSwitch ("/delaysign+");
commandLine.AppendSwitch ("/delaysign-");
if (Bag ["EmitDebugInformation"] != null)
if (EmitDebugInformation)
- commandLine.AppendSwitch ("/debug+");
+ commandLine.AppendSwitch ("/debug:portable");
else
commandLine.AppendSwitch ("/debug-");
//fileAlignment
commandLine.AppendSwitchIfNotNull ("/keycontainer:", KeyContainer);
commandLine.AppendSwitchIfNotNull ("/keyfile:", KeyFile);
+ if (KeyFile != null && !DelaySign)
+ commandLine.AppendSwitch("/publicsign");
+
// FIXME: add ids from metadata
- if (LinkResources != null) {
- foreach (ITaskItem item in LinkResources) {
+ if (LinkResources != null)
+ foreach (ITaskItem item in LinkResources)
commandLine.AppendSwitchIfNotNull ("/linkresource:", item.ItemSpec);
- }
- }
- commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);
+
if (NoLogo)
commandLine.AppendSwitch ("/nologo");
+
if (Bag ["Optimize"] != null)
if (Optimize)
commandLine.AppendSwitch ("/optimize+");
else
commandLine.AppendSwitch ("/optimize-");
+
if (OutputAssembly != null)
commandLine.AppendSwitchIfNotNull ("/out:", OutputAssembly.ItemSpec);
- if (References != null) {
- foreach (ITaskItem item in References) {
- commandLine.AppendSwitchIfNotNull ("/reference:", item.ItemSpec);
- }
- }
- if (Resources != null) {
+
+ if (Resources != null)
foreach (ITaskItem item in Resources) {
+ string logical_name = item.GetMetadata ("LogicalName");
+ if (logical_name.Length > 0)
+ commandLine.AppendSwitchIfNotNull ("/resource:",
+ String.Format ("{0},{1}", item.ItemSpec, logical_name));
+ else
commandLine.AppendSwitchIfNotNull ("/resource:", item.ItemSpec);
}
- }
- if (ResponseFiles != null) {
- foreach (ITaskItem item in ResponseFiles) {
- commandLine.AppendFileNameIfNotNull (String.Format ("@{0}",item.ItemSpec));
- }
- }
- if (Sources != null) {
- foreach (ITaskItem item in Sources) {
+
+ if (Sources != null)
+ foreach (ITaskItem item in Sources)
commandLine.AppendFileNameIfNotNull (item.ItemSpec);
- }
- }
+
if (TargetType != null)
commandLine.AppendSwitchIfNotNull ("/target:", TargetType);
if (Bag ["TreatWarningsAsErrors"] != null)
else
commandLine.AppendSwitch ("/warnaserror-");
commandLine.AppendSwitchIfNotNull ("/win32icon:", Win32Icon);
- commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource);
}
[MonoTODO]
[MonoTODO]
protected override bool HandleTaskExecutionErrors ()
{
- return true;
+ if (!Log.HasLoggedErrors && ExitCode != 0)
+ Log.LogError ("Compiler crashed with code: {0}.", ExitCode);
+
+ return ExitCode == 0 && !Log.HasLoggedErrors;
}
[MonoTODO]
- protected bool ListHasNoDuplicateItems (ITaskItem[] itemList,
+ protected bool ListHasNoDuplicateItems (ITaskItem [] itemList,
string parameterName)
{
- Hashtable items = new Hashtable ();
+ Dictionary <string, object> items = new Dictionary <string, object> ();
foreach (ITaskItem item in itemList) {
- if (items.Contains (item.ItemSpec))
+ if (!items.ContainsKey (item.ItemSpec))
items.Add (item.ItemSpec, null);
else
return false;
return true;
}
+ protected internal virtual bool UseAlternateCommandLineToolToExecute ()
+ {
+ //
+ // If an alternate tool name or tool path was specified in the project file, then that tool is used
+ // rather than the host compiler for integrated development environment (IDE) builds.
+ //
+ return !string.IsNullOrEmpty (ToolPath) || ToolName != ToolExe;
+ }
+
[MonoTODO]
protected override bool ValidateParameters ()
{
public ITaskItem[] Sources {
get { return (ITaskItem[]) Bag ["Sources"]; }
- // FIXME: setting sources changes OutputAssembly
- set { Bag ["Sources"] = value; }
+ set {
+ Bag ["Sources"] = value;
+ if (Bag ["OutputAssembly"] == null && value != null && value.Length >= 1)
+ Bag ["OutputAssembly"] = new TaskItem (String.Format ("{0}.exe", value [0].ItemSpec));
+ }
}
protected override Encoding StandardOutputEncoding {
get { return Console.Error.Encoding; }
}
- // FIXME: hack to get build of hello world working
public string TargetType {
get {
- return (Bag.Contains ("TargetType")) ? (((string) Bag ["TargetType"]).ToLower ()) : null;
+ if (Bag.Contains ("TargetType")) {
+ string s = (string) Bag ["TargetType"];
+ return s.ToLowerInvariant ();
+ } else
+ return null;
}
set { Bag ["TargetType"] = value; }
}
}
}
-#endif