protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine) { 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 exception) { throw new ArgumentException(exception.Message, "Sources"); } if (string.Compare(this.TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0) { ITaskItem outputAssembly = this.OutputAssembly; outputAssembly.ItemSpec = outputAssembly.ItemSpec + ".dll"; } else if (string.Compare(this.TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0) { ITaskItem item2 = this.OutputAssembly; item2.ItemSpec = item2.ItemSpec + ".netmodule"; } else { ITaskItem item3 = this.OutputAssembly; item3.ItemSpec = item3.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"); commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly); commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" }); 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); commandLine.AppendFileNamesIfNotNull(this.Sources, " "); }
protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine) { commandLine.AppendSwitchIfNotNull("/lib:", base.AdditionalLibPaths, ","); commandLine.AppendPlusOrMinusSwitch("/unsafe", base.Bag, "AllowUnsafeBlocks"); commandLine.AppendPlusOrMinusSwitch("/checked", base.Bag, "CheckForOverflowUnderflow"); commandLine.AppendSwitchWithSplitting("/nowarn:", this.DisabledWarnings, ",", new char[] { ';', ',' }); commandLine.AppendWhenTrue("/fullpaths", base.Bag, "GenerateFullPaths"); commandLine.AppendSwitchIfNotNull("/langversion:", this.LangVersion); commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", this.ModuleAssemblyName); commandLine.AppendSwitchIfNotNull("/pdb:", this.PdbFile); commandLine.AppendPlusOrMinusSwitch("/nostdlib", base.Bag, "NoStandardLib"); commandLine.AppendSwitchIfNotNull("/platform:", this.Platform); commandLine.AppendSwitchIfNotNull("/errorreport:", this.ErrorReport); commandLine.AppendSwitchWithInteger("/warn:", base.Bag, "WarningLevel"); commandLine.AppendSwitchIfNotNull("/doc:", this.DocumentationFile); commandLine.AppendSwitchIfNotNull("/baseaddress:", this.BaseAddress); commandLine.AppendSwitchUnquotedIfNotNull("/define:", this.GetDefineConstantsSwitch(base.DefineConstants)); commandLine.AppendSwitchIfNotNull("/win32res:", base.Win32Resource); commandLine.AppendSwitchIfNotNull("/main:", base.MainEntryPoint); commandLine.AppendSwitchIfNotNull("/appconfig:", this.ApplicationConfiguration); this.AddReferencesToCommandLine(commandLine); base.AddResponseFileCommands(commandLine); commandLine.AppendSwitchWithSplitting("/warnaserror+:", this.WarningsAsErrors, ",", new char[] { ';', ',' }); commandLine.AppendSwitchWithSplitting("/warnaserror-:", this.WarningsNotAsErrors, ",", new char[] { ';', ',' }); if (base.ResponseFiles != null) { foreach (ITaskItem item in base.ResponseFiles) { commandLine.AppendSwitchIfNotNull("@", item.ItemSpec); } } }
/// <summary> /// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file. /// </summary> protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine) { // If outputAssembly is not specified, then an "/out: <name>" option won't be added to // overwrite the one resulting from the OutputAssembly member of the CompilerParameters class. // In that case, we should set the outputAssembly member based on the first source file. if ( (OutputAssembly == null) && (Sources != null) && (Sources.Length > 0) && (this.ResponseFiles == null) // The response file may already have a /out: switch in it, so don't try to be smart here. ) { try { OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(Sources[0].ItemSpec)); } catch (ArgumentException e) { throw new ArgumentException(e.Message, "Sources"); } if (String.Compare(TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0) { OutputAssembly.ItemSpec += ".dll"; } else if (String.Compare(TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0) { OutputAssembly.ItemSpec += ".netmodule"; } else { OutputAssembly.ItemSpec += ".exe"; } } commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ","); commandLine.AppendSwitchWithInteger("/codepage:", this.Bag, "CodePage"); ConfigureDebugProperties(); // The "DebugType" parameter should be processed after the "EmitDebugInformation" parameter // because it's more specific. Order matters on the command-line, and the last one wins. // /debug+ is just a shorthand for /debug:full. And /debug- is just a shorthand for /debug:none. commandLine.AppendPlusOrMinusSwitch("/debug", this.Bag, "EmitDebugInformation"); commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType); commandLine.AppendPlusOrMinusSwitch("/delaysign", this.Bag, "DelaySign"); commandLine.AppendSwitchWithInteger("/filealign:", this.Bag, "FileAlignment"); commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer); commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile); // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject. commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] { "LogicalName", "Access" }); commandLine.AppendWhenTrue("/nologo", this.Bag, "NoLogo"); commandLine.AppendWhenTrue("/nowin32manifest", this.Bag, "NoWin32Manifest"); commandLine.AppendPlusOrMinusSwitch("/optimize", this.Bag, "Optimize"); commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly); commandLine.AppendSwitchIfNotNull("/ruleset:", this.CodeAnalysisRuleSet); commandLine.AppendSwitchIfNotNull("/subsystemversion:", this.SubsystemVersion); // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject. commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" }); commandLine.AppendSwitchIfNotNull("/target:", this.TargetType); commandLine.AppendPlusOrMinusSwitch("/warnaserror", this.Bag, "TreatWarningsAsErrors"); commandLine.AppendWhenTrue("/utf8output", this.Bag, "Utf8Output"); commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon); commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest); // Append the analyzers. this.AddAnalyzersToCommandLine(commandLine); // Append additional files. this.AddAdditionalFilesToCommandLine(commandLine); // Append the sources. commandLine.AppendFileNamesIfNotNull(Sources, " "); }
/// <summary> /// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file. /// </summary> override protected internal void AddResponseFileCommands(CommandLineBuilderExtension commandLine) { commandLine.AppendSwitchIfNotNull("/lib:", this.AdditionalLibPaths, ","); commandLine.AppendPlusOrMinusSwitch("/unsafe", this.Bag, "AllowUnsafeBlocks"); commandLine.AppendPlusOrMinusSwitch("/checked", this.Bag, "CheckForOverflowUnderflow"); commandLine.AppendSwitchWithSplitting("/nowarn:", this.DisabledWarnings, ",", ';', ','); commandLine.AppendWhenTrue("/fullpaths", this.Bag, "GenerateFullPaths"); commandLine.AppendSwitchIfNotNull("/langversion:", this.LangVersion); commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", this.ModuleAssemblyName); commandLine.AppendSwitchIfNotNull("/pdb:", this.PdbFile); commandLine.AppendPlusOrMinusSwitch("/nostdlib", this.Bag, "NoStandardLib"); commandLine.AppendSwitchIfNotNull("/platform:", this.PlatformWith32BitPreference); commandLine.AppendSwitchIfNotNull("/errorreport:", this.ErrorReport); commandLine.AppendSwitchWithInteger("/warn:", this.Bag, "WarningLevel"); commandLine.AppendSwitchIfNotNull("/doc:", this.DocumentationFile); commandLine.AppendSwitchIfNotNull("/baseaddress:", this.BaseAddress); commandLine.AppendSwitchUnquotedIfNotNull("/define:", this.GetDefineConstantsSwitch(this.DefineConstants)); commandLine.AppendSwitchIfNotNull("/win32res:", this.Win32Resource); commandLine.AppendSwitchIfNotNull("/main:", this.MainEntryPoint); commandLine.AppendSwitchIfNotNull("/appconfig:", this.ApplicationConfiguration); commandLine.AppendWhenTrue("/errorendlocation", this.Bag, "ErrorEndLocation"); commandLine.AppendSwitchIfNotNull("/preferreduilang:", this.PreferredUILang); commandLine.AppendPlusOrMinusSwitch("/highentropyva", this.Bag, "HighEntropyVA"); // If not design time build and the globalSessionGuid property was set then add a -globalsessionguid:<guid> bool designTime = false; if (this.HostObject != null) { var csHost = this.HostObject as ICscHostObject; designTime = csHost.IsDesignTime(); } if (!designTime) { if (!string.IsNullOrWhiteSpace(this.VsSessionGuid)) { commandLine.AppendSwitchIfNotNull("/sqmsessionguid:", this.VsSessionGuid); } } this.AddReferencesToCommandLine(commandLine); base.AddResponseFileCommands(commandLine); // This should come after the "TreatWarningsAsErrors" flag is processed (in managedcompiler.cs). // Because if TreatWarningsAsErrors=false, then we'll have a /warnaserror- on the command-line, // and then any specific warnings that should be treated as errors should be specified with // /warnaserror+:<list> after the /warnaserror- switch. The order of the switches on the command-line // does matter. // // Note that // /warnaserror+ // is just shorthand for: // /warnaserror+:<all possible warnings> // // Similarly, // /warnaserror- // is just shorthand for: // /warnaserror-:<all possible warnings> commandLine.AppendSwitchWithSplitting("/warnaserror+:", this.WarningsAsErrors, ",", ';', ','); commandLine.AppendSwitchWithSplitting("/warnaserror-:", this.WarningsNotAsErrors, ",", ';', ','); // It's a good idea for the response file to be the very last switch passed, just // from a predictability perspective. if (this.ResponseFiles != null) { foreach (ITaskItem response in this.ResponseFiles) { commandLine.AppendSwitchIfNotNull("@", response.ItemSpec); } } }