This documentation is archived and is not being maintained.

CommandLineBuilder Class

Comprises utility methods for constructing a command line.

System::Object
  Microsoft.Build.Utilities::CommandLineBuilder
    Microsoft.Build.Tasks::CommandLineBuilderExtension

Namespace:  Microsoft.Build.Utilities
Assembly:  Microsoft.Build.Utilities.v4.0 (in Microsoft.Build.Utilities.v4.0.dll)

public ref class CommandLineBuilder

The CommandLineBuilder type exposes the following members.

  NameDescription
Public methodCommandLineBuilder()Initializes a new instance of the CommandLineBuilder class.
Public methodCommandLineBuilder(Boolean)Default constructor
Top

  NameDescription
Protected propertyCommandLineGets the StringBuilder instance representing the command line for inheriting classes.
Public propertyLengthRepresents the length of the command line.
Top

  NameDescription
Public methodAppendFileNameIfNotNull(ITaskItem)Appends the command line with the file name of the specified ITaskItem object.
Public methodAppendFileNameIfNotNull(String)Appends the command line with file name represented by the parameter, inserting quotation marks if necessary.
Public methodAppendFileNamesIfNotNull(array<ITaskItem>, String)Appends the command line with the list of file names in the specified ITaskItem array, separated by the specified delimiter.
Public methodAppendFileNamesIfNotNull(array<String>, String)Appends the command line with the list of file names in the specified string array, separated by the specified delimiter.
Protected methodAppendFileNameWithQuotingAppends the command line with a file name, and surrounds the file name with quotation marks as necessary.
Protected methodAppendQuotedTextToBufferAppends given text to the buffer after first quoting the text if necessary.
Protected methodAppendSpaceIfNotEmptyAdds a space to the specified string, given the string is not empty.
Public methodAppendSwitchAppends the command line with the specified switch.
Public methodAppendSwitchIfNotNull(String, ITaskItem)Appends the command line with a switch that takes a task item specification that acts a single string parameter.
Public methodAppendSwitchIfNotNull(String, String)Appends the command line with a switch that takes a single string parameter.
Public methodAppendSwitchIfNotNull(String, array<ITaskItem>, String)Appends the command line with a switch that takes an array of task item specifications that act as string parameters.
Public methodAppendSwitchIfNotNull(String, array<String>, String)Appends the command line with a switch that takes an array of string parameters.
Public methodAppendSwitchUnquotedIfNotNull(String, ITaskItem)Appends the command line with a switch that takes a task item specification as a single string parameter, without attempting to encapsulate the switch parameter with quotation marks.
Public methodAppendSwitchUnquotedIfNotNull(String, String)Appends the command line with a switch that takes a single string parameter, without attempting to encapsulate the switch parameter with quotation marks.
Public methodAppendSwitchUnquotedIfNotNull(String, array<ITaskItem>, String)Appends the command line with a switch that takes an array of task item specifications that act as string parameters, without attempting to encapsulate them with quotation marks.
Public methodAppendSwitchUnquotedIfNotNull(String, array<String>, String)Appends the command line with a switch that takes an array of string parameters, without attempting to encapsulate switch parameters with quotation marks.
Public methodAppendTextUnquotedAppends the command line with string, without attempting to encapsulate the string with quotation marks.
Protected methodAppendTextWithQuotingAppends the command line with string, and surrounds the string with quotations marks as necessary.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodIsQuotingRequiredDetermines whether the specified string parameter should be surrounded with quotation marks because it contains white space.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns the command line as a string. (Overrides Object::ToString().)
Protected methodVerifyThrowNoEmbeddedDoubleQuotesReturns an error if the command line parameter contains a double-quote (") character. Because double quotes are illegal in command line parameters, this method helps prevent parameter injection attacks.
Top

The following example creates a ToolTask that runs Ilasm.exe (MSIL Assembler). The CommandLineBuilder, ToolLocationHelper, and TaskLoggingHelper classes are used to generate the information needed to run the task.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: