/// <summary> /// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file. /// </summary> protected internal virtual 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) && (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:", AddModules, ","); commandLine.AppendSwitchWithInteger("/codepage:", _store, nameof(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", _store, nameof(EmitDebugInformation)); commandLine.AppendSwitchIfNotNull("/debug:", DebugType); commandLine.AppendPlusOrMinusSwitch("/delaysign", _store, nameof(DelaySign)); commandLine.AppendSwitchWithInteger("/filealign:", _store, nameof(FileAlignment)); commandLine.AppendSwitchIfNotNull("/keycontainer:", KeyContainer); commandLine.AppendSwitchIfNotNull("/keyfile:", KeyFile); // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject. commandLine.AppendSwitchIfNotNull("/linkresource:", LinkResources, new string[] { "LogicalName", "Access" }); commandLine.AppendWhenTrue("/nologo", _store, nameof(NoLogo)); commandLine.AppendWhenTrue("/nowin32manifest", _store, nameof(NoWin32Manifest)); commandLine.AppendPlusOrMinusSwitch("/optimize", _store, nameof(Optimize)); commandLine.AppendSwitchIfNotNull("/pathmap:", PathMap); commandLine.AppendSwitchIfNotNull("/out:", OutputAssembly); commandLine.AppendSwitchIfNotNull("/ruleset:", CodeAnalysisRuleSet); commandLine.AppendSwitchIfNotNull("/errorlog:", ErrorLog); commandLine.AppendSwitchIfNotNull("/subsystemversion:", SubsystemVersion); commandLine.AppendWhenTrue("/reportanalyzer", _store, nameof(ReportAnalyzer)); // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject. commandLine.AppendSwitchIfNotNull("/resource:", Resources, new string[] { "LogicalName", "Access" }); commandLine.AppendSwitchIfNotNull("/target:", TargetType); commandLine.AppendPlusOrMinusSwitch("/warnaserror", _store, nameof(TreatWarningsAsErrors)); commandLine.AppendWhenTrue("/utf8output", _store, nameof(Utf8Output)); commandLine.AppendSwitchIfNotNull("/win32icon:", Win32Icon); commandLine.AppendSwitchIfNotNull("/win32manifest:", Win32Manifest); AddResponseFileCommandsForSwitchesSinceInitialReleaseThatAreNeededByTheHost(commandLine); AddAnalyzersToCommandLine(commandLine, Analyzers); 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._store, "AllowUnsafeBlocks"); commandLine.AppendPlusOrMinusSwitch("/checked", this._store, "CheckForOverflowUnderflow"); commandLine.AppendSwitchWithSplitting("/nowarn:", this.DisabledWarnings, ",", ';', ','); commandLine.AppendWhenTrue("/fullpaths", this._store, "GenerateFullPaths"); commandLine.AppendSwitchIfNotNull("/langversion:", this.LangVersion); commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", this.ModuleAssemblyName); commandLine.AppendSwitchIfNotNull("/pdb:", this.PdbFile); commandLine.AppendPlusOrMinusSwitch("/nostdlib", this._store, "NoStandardLib"); commandLine.AppendSwitchIfNotNull("/platform:", this.PlatformWith32BitPreference); commandLine.AppendSwitchIfNotNull("/errorreport:", this.ErrorReport); commandLine.AppendSwitchWithInteger("/warn:", this._store, "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._store, "ErrorEndLocation"); commandLine.AppendSwitchIfNotNull("/preferreduilang:", this.PreferredUILang); commandLine.AppendPlusOrMinusSwitch("/highentropyva", this._store, "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. It also solves the problem that a dogfooder // ran into, which is described in an email thread attached to bug VSWhidbey 146883. // See also bugs 177762 and 118307 for additional bugs related to response file position. if (this.ResponseFiles != null) { foreach (ITaskItem response in this.ResponseFiles) { commandLine.AppendSwitchIfNotNull("@", response.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) { commandLine.AppendSwitchIfNotNull("/lib:", AdditionalLibPaths, ","); commandLine.AppendPlusOrMinusSwitch("/unsafe", _store, nameof(AllowUnsafeBlocks)); commandLine.AppendPlusOrMinusSwitch("/checked", _store, nameof(CheckForOverflowUnderflow)); commandLine.AppendSwitchWithSplitting("/nowarn:", DisabledWarnings, ",", ';', ','); commandLine.AppendWhenTrue("/fullpaths", _store, nameof(GenerateFullPaths)); commandLine.AppendSwitchIfNotNull("/langversion:", LangVersion); commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", ModuleAssemblyName); commandLine.AppendSwitchIfNotNull("/pdb:", PdbFile); commandLine.AppendPlusOrMinusSwitch("/nostdlib", _store, nameof(NoStandardLib)); commandLine.AppendSwitchIfNotNull("/platform:", PlatformWith32BitPreference); commandLine.AppendSwitchIfNotNull("/errorreport:", ErrorReport); commandLine.AppendSwitchWithInteger("/warn:", _store, nameof(WarningLevel)); commandLine.AppendSwitchIfNotNull("/doc:", DocumentationFile); commandLine.AppendSwitchIfNotNull("/baseaddress:", BaseAddress); commandLine.AppendSwitchUnquotedIfNotNull("/define:", GetDefineConstantsSwitch(DefineConstants, Log)); commandLine.AppendSwitchIfNotNull("/win32res:", Win32Resource); commandLine.AppendSwitchIfNotNull("/main:", MainEntryPoint); commandLine.AppendSwitchIfNotNull("/appconfig:", ApplicationConfiguration); commandLine.AppendWhenTrue("/errorendlocation", _store, nameof(ErrorEndLocation)); commandLine.AppendSwitchIfNotNull("/preferreduilang:", PreferredUILang); commandLine.AppendPlusOrMinusSwitch("/highentropyva", _store, nameof(HighEntropyVA)); // If not design time build and the globalSessionGuid property was set then add a -globalsessionguid:<guid> bool designTime = false; if (HostObject != null) { var csHost = HostObject as ICscHostObject; designTime = csHost.IsDesignTime(); } if (!designTime) { if (!string.IsNullOrWhiteSpace(VsSessionGuid)) { commandLine.AppendSwitchIfNotNull("/sqmsessionguid:", VsSessionGuid); } } AddReferencesToCommandLine(commandLine, References); 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+:", WarningsAsErrors, ",", ';', ','); commandLine.AppendSwitchWithSplitting("/warnaserror-:", WarningsNotAsErrors, ",", ';', ','); // It's a good idea for the response file to be the very last switch passed, just // from a predictability perspective. It also solves the problem that a dogfooder // ran into, which is described in an email thread attached to bug VSWhidbey 146883. // See also bugs 177762 and 118307 for additional bugs related to response file position. if (ResponseFiles != null) { foreach (ITaskItem response in ResponseFiles) { commandLine.AppendSwitchIfNotNull("@", response.ItemSpec); } } }
/// <summary> /// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file. /// </summary> protected internal virtual 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._store, "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._store, "EmitDebugInformation"); commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType); commandLine.AppendPlusOrMinusSwitch("/delaysign", this._store, "DelaySign"); commandLine.AppendSwitchWithInteger("/filealign:", this._store, "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._store, "NoLogo"); commandLine.AppendWhenTrue("/nowin32manifest", this._store, "NoWin32Manifest"); commandLine.AppendPlusOrMinusSwitch("/optimize", this._store, "Optimize"); commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly); commandLine.AppendSwitchIfNotNull("/ruleset:", this.CodeAnalysisRuleSet); commandLine.AppendSwitchIfNotNull("/errorlog:", this.ErrorLog); commandLine.AppendSwitchIfNotNull("/subsystemversion:", this.SubsystemVersion); commandLine.AppendWhenTrue("/reportanalyzer", this._store, "ReportAnalyzer"); // 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._store, "TreatWarningsAsErrors"); commandLine.AppendWhenTrue("/utf8output", this._store, "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, " "); }