X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FMicrosoft.Build.Tasks%2FMicrosoft.Build.Tasks%2FCsc.cs;h=142e73eddeb802dc009295d558a072bb7957652a;hb=5ad1099341581dee94f77b32db728918e90fa64f;hp=fff7e3fa5cccf93d0e66d288408fc278d061673f;hpb=434e59e4bc6cda7d62ad6725a8b5a590ff9c9d1f;p=mono.git diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs index fff7e3fa5cc..142e73eddeb 100644 --- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs +++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs @@ -32,6 +32,7 @@ using System.IO; 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 { @@ -42,9 +43,15 @@ namespace Microsoft.Build.Tasks { 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+"); @@ -59,9 +66,20 @@ namespace Microsoft.Build.Tasks { 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); @@ -80,14 +98,21 @@ namespace Microsoft.Build.Tasks { 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 ()); @@ -97,7 +122,7 @@ namespace Microsoft.Build.Tasks { commandLine.AppendSwitchIfNotNull ("/warnaserror-:", WarningsNotAsErrors); if (Win32Resource != null) - commandLine.AppendSwitchIfNotNull ("/win32res:", String.Format ("\"{0}\"", Win32Resource)); + commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource); } [MonoTODO] @@ -108,7 +133,9 @@ namespace Microsoft.Build.Tasks { 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] @@ -178,7 +205,9 @@ namespace Microsoft.Build.Tasks { } protected override string ToolName { - get { return "gmcs"; } + get { + return "mcs.exe"; + } } public bool UseHostCompilerIfAvailable {