public override bool Execute() { var outputAssembly = OutputAssembly.ItemSpec; OutputGeneratedDir = Path.GetDirectoryName(outputAssembly); AssemblyFilenameWithoutExtension = Path.GetFileNameWithoutExtension(outputAssembly); OutputAssembly.ItemSpec = Path.Combine(OutputGeneratedDir, Path.GetFileName(outputAssembly)); if (UseBuildService) { var args = new CompilerToolArgs(); AddResponseFileCommands2(args); var res = new CompilerServiceClient().Compile(new CompileRequest { Args = args }); foreach (var s in res.Output) { LogEventsFromTextOutput(s, MessageImportance.High); } return(res.ExitCode == 0); } else { var success = base.Execute(); return(success); } }
protected void AddResponseFileCommands2(CompilerToolArgs args) { if (OutputGeneratedFile != null && !String.IsNullOrEmpty(OutputGeneratedFile.ItemSpec)) { args.OutputGeneratedFile = OutputGeneratedFile.ItemSpec; } args.define = this.GetDefineConstantsSwitch(base.DefineConstants); this.AddReferencesToCommandLine2(args); BaseAddResponseFileCommands(args); if (ResponseFiles != null) { foreach (ITaskItem item in ResponseFiles) { throw new Exception(); //commandLine.AppendSwitchIfNotNull("@", item.ItemSpec); } } if (ContentFiles != null) { foreach (var file in ContentFiles) { args.ContentFiles.Add(file.ItemSpec); } } if (NoneFiles != null) { foreach (var file in NoneFiles) { args.NoneFiles.Add(file.ItemSpec); } } if (SkcPlugins != null) { foreach (var file in SkcPlugins) { args.Plugins.Add(file.ItemSpec); } } if (SkcRebuild) { args.rebuild = true; } if (UseBuildService) { args.CurrentDirectory = Directory.GetCurrentDirectory(); } args.TargetFrameworkVersion = TargetFrameworkVersion; }
private void AddReferencesToCommandLine2(CompilerToolArgs args) { if ((base.References != null) && (base.References.Length != 0)) { foreach (ITaskItem item in base.References) { string metadata = item.GetMetadata("Aliases"); if ((metadata == null) || (metadata.Length == 0)) { args.References.Add(item.ItemSpec); } else { foreach (string str2 in metadata.Split(new char[] { ',' })) { string str3 = str2.Trim(); if (str2.Length != 0) { if (str3.IndexOfAny(new char[] { ',', ' ', ';', '"' }) != -1) { throw new ArgumentException("Csc.AssemblyAliasContainsIllegalCharacters" + item.ItemSpec + str3); } if (string.Compare("global", str3, StringComparison.OrdinalIgnoreCase) == 0) { args.References.Add(item.ItemSpec); } else { throw new NotImplementedException("TODO: Implement"); //commandLine.AppendSwitchAliased("/reference:", str3, item.ItemSpec); } } } } } } }
void BaseAddResponseFileCommands(CompilerToolArgs args) { if (this.OutputAssembly == null && this.Sources != null && this.Sources.Length > 0 && this.ResponseFiles == null) { try { this.OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(this.Sources[0].ItemSpec)); } catch (ArgumentException ex) { throw new ArgumentException(ex.Message, "Sources"); } if (string.Compare(this.TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0) { ITaskItem expr_79 = this.OutputAssembly; expr_79.ItemSpec += ".dll"; } else { if (string.Compare(this.TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0) { ITaskItem expr_A9 = this.OutputAssembly; expr_A9.ItemSpec += ".netmodule"; } else { ITaskItem expr_C6 = this.OutputAssembly; expr_C6.ItemSpec += ".exe"; } } } // commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ","); // commandLine.AppendSwitchWithInteger("/codepage:", base.Bag, "CodePage"); // this.ConfigureDebugProperties(); // commandLine.AppendPlusOrMinusSwitch("/debug", base.Bag, "EmitDebugInformation"); // commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType); // commandLine.AppendPlusOrMinusSwitch("/delaysign", base.Bag, "DelaySign"); // commandLine.AppendSwitchWithInteger("/filealign:", base.Bag, "FileAlignment"); // commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer); // commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile); // commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] //{ // "LogicalName", // "Access" //}); // commandLine.AppendWhenTrue("/nologo", base.Bag, "NoLogo"); // commandLine.AppendWhenTrue("/nowin32manifest", base.Bag, "NoWin32Manifest"); // commandLine.AppendPlusOrMinusSwitch("/optimize", base.Bag, "Optimize"); args.Output = OutputAssembly.ItemSpec; //commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly); // commandLine.AppendSwitchIfNotNull("/subsystemversion:", this.SubsystemVersion); // commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] //{ // "LogicalName", // "Access" //}); args.Target = TargetType; //commandLine.AppendSwitchIfNotNull("/target:", this.TargetType); //commandLine.AppendPlusOrMinusSwitch("/warnaserror", base.Bag, "TreatWarningsAsErrors"); //commandLine.AppendWhenTrue("/utf8output", base.Bag, "Utf8Output"); //commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon); //commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest); args.Files.AddRange(Sources.Select(t => t.ItemSpec).ToList()); //commandLine.AppendFileNamesIfNotNull(this.Sources, " "); }