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 {
{
}
- [MonoTODO]
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);
-
- if (AllowUnsafeBlocks == true)
- commandLine.AppendSwitch ("/unsafe");
+
+ if (AdditionalLibPaths != null && AdditionalLibPaths.Length > 0)
+ commandLine.AppendSwitchIfNotNull ("/lib:", AdditionalLibPaths, ",");
+
+ if (Bag ["AllowUnsafeBlocks"] != null)
+ if (AllowUnsafeBlocks)
+ commandLine.AppendSwitch ("/unsafe+");
+ else
+ commandLine.AppendSwitch ("/unsafe-");
+
//baseAddress
- //checkForOverflowUnderflow
- commandLine.AppendSwitchIfNotNull ("/nowarn:", DisabledWarnings);
+
+ if (Bag ["CheckForOverflowUnderflow"] != null)
+ if (CheckForOverflowUnderflow)
+ commandLine.AppendSwitch ("/checked+");
+ else
+ commandLine.AppendSwitch ("/checked-");
+
+ 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);
+
//errorReport
+
+ if (GenerateFullPaths)
+ commandLine.AppendSwitch ("/fullpaths");
+
commandLine.AppendSwitchIfNotNull ("/langversion:", LangVersion);
+
+ commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);
+
//moduleAssemblyName
+
if (NoStandardLib)
commandLine.AppendSwitch ("/nostdlib");
+
//platform
- commandLine.AppendSwitchIfNotNull ("/warn:", WarningLevel.ToString ());
- //warningsAsErrors
- //warningNotAsErrors
+ commandLine.AppendSwitchIfNotNull ("/platform:", Platform);
+ //
+ if (References != null)
+ 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.AppendSwitchIfNotNull ("@", item.ItemSpec);
+
+ if (Bag ["WarningLevel"] != null)
+ commandLine.AppendSwitchIfNotNull ("/warn:", WarningLevel.ToString ());
+
+ commandLine.AppendSwitchIfNotNull ("/warnaserror+:", WarningsAsErrors);
+
+ commandLine.AppendSwitchIfNotNull ("/warnaserror-:", WarningsNotAsErrors);
+
+ if (Win32Resource != null)
+ 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 {
}
public int WarningLevel {
- get { return GetIntParameterWithDefault ("WarningLevel", 2); }
+ get { return GetIntParameterWithDefault ("WarningLevel", 4); }
set { Bag ["WarningLevel"] = value; }
}