using Microsoft.Build.Framework;
using Microsoft.Build.Tasks.Hosting;
using Microsoft.Build.Utilities;
+using Mono.XBuild.Utilities;
namespace Microsoft.Build.Tasks {
public class Csc : ManagedCompiler {
protected internal override void AddResponseFileCommands (CommandLineBuilderExtension commandLine)
{
+#if !NET_4_0
+ //pre-MSBuild 2 targets don't support multi-targeting, so tell compiler to use 2.0 corlib
+ commandLine.AppendSwitch ("/sdk:2");
+#endif
base.AddResponseFileCommands (commandLine);
- commandLine.AppendSwitchIfNotNull ("/lib:", AdditionalLibPaths, ",");
+ if (AdditionalLibPaths != null && AdditionalLibPaths.Length > 0)
+ commandLine.AppendSwitchIfNotNull ("/lib:", AdditionalLibPaths, ",");
+
if (Bag ["AllowUnsafeBlocks"] != null)
if (AllowUnsafeBlocks)
commandLine.AppendSwitch ("/unsafe+");
else
commandLine.AppendSwitch ("/checked-");
- commandLine.AppendSwitchIfNotNull ("/define:", DefineConstants);
-
- commandLine.AppendSwitchIfNotNull ("/nowarn:", DisabledWarnings);
+ if (!String.IsNullOrEmpty (DefineConstants)) {
+ string [] defines = DefineConstants.Split (new char [] {';', ' '},
+ StringSplitOptions.RemoveEmptyEntries);
+ if (defines.Length > 0)
+ commandLine.AppendSwitchIfNotNull ("/define:",
+ String.Join (";", defines));
+ }
+
+ if (!String.IsNullOrEmpty (DisabledWarnings)) {
+ string [] defines = DisabledWarnings.Split (new char [] {';', ' ', ','},
+ StringSplitOptions.RemoveEmptyEntries);
+ if (defines.Length > 0)
+ commandLine.AppendSwitchIfNotNull ("/nowarn:", defines, ";");
+ }
commandLine.AppendSwitchIfNotNull ("/doc:", DocumentationFile);
commandLine.AppendSwitch ("/nostdlib");
//platform
+ commandLine.AppendSwitchIfNotNull ("/platform:", Platform);
//
if (References != null)
- foreach (ITaskItem item in References)
- commandLine.AppendSwitchIfNotNull ("/reference:", item.ItemSpec);
+ foreach (ITaskItem item in References) {
+ string aliases = item.GetMetadata ("Aliases") ?? String.Empty;
+ aliases = aliases.Trim ();
+ if (aliases.Length > 0)
+ commandLine.AppendSwitchIfNotNull ("/reference:" + aliases + "=", item.ItemSpec);
+ else
+ commandLine.AppendSwitchIfNotNull ("/reference:", item.ItemSpec);
+ }
if (ResponseFiles != null)
foreach (ITaskItem item in ResponseFiles)
- commandLine.AppendFileNameIfNotNull (String.Format ("@{0}",item.ItemSpec));
+ commandLine.AppendSwitchIfNotNull ("@", item.ItemSpec);
if (Bag ["WarningLevel"] != null)
commandLine.AppendSwitchIfNotNull ("/warn:", WarningLevel.ToString ());
commandLine.AppendSwitchIfNotNull ("/warnaserror-:", WarningsNotAsErrors);
if (Win32Resource != null)
- commandLine.AppendSwitchIfNotNull ("/win32res:", String.Format ("\"{0}\"", Win32Resource));
+ commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource);
}
[MonoTODO]
protected override string GenerateFullPathToTool ()
{
- return Path.Combine (ToolPath, ToolName);
+ if (!string.IsNullOrEmpty (ToolPath))
+ return Path.Combine (ToolPath, ToolExe);
+ return ToolLocationHelper.GetPathToDotNetFrameworkFile (ToolExe, TargetDotNetFrameworkVersion.VersionLatest);
}
[MonoTODO]
}
protected override string ToolName {
- get { return "gmcs"; }
+ get {
+ return "mcs.exe";
+ }
}
public bool UseHostCompilerIfAvailable {