Compartilhar via


CommandLineBuilder.AppendSwitchIfNotNull Method

Definition

Appends the command line with a switch.

Overloads

AppendSwitchIfNotNull(String, String[], String)

Appends a command-line switch that takes a string[] parameter, and add double-quotes around the individual filenames if necessary. This method appends a space to the command line (if it's not currently empty) before the switch.

AppendSwitchIfNotNull(String, ITaskItem[], String)

Appends a command-line switch that takes a ITaskItem[] parameter, and add double-quotes around the individual filenames if necessary. This method appends a space to the command line (if it's not currently empty) before the switch.

AppendSwitchIfNotNull(String, String)

Appends a command-line switch that takes a single string parameter, quoting the parameter if necessary. This method appends a space to the command line (if it's not currently empty) before the switch.

AppendSwitchIfNotNull(String, ITaskItem)

Append a switch [overload] This method appends a space to the command line (if it's not currently empty) before the switch.

AppendSwitchIfNotNull(String, String[], String)

Source:
CommandLineBuilder.cs

Appends a command-line switch that takes a string[] parameter, and add double-quotes around the individual filenames if necessary. This method appends a space to the command line (if it's not currently empty) before the switch.

public:
 void AppendSwitchIfNotNull(System::String ^ switchName, cli::array <System::String ^> ^ parameters, System::String ^ delimiter);
public void AppendSwitchIfNotNull (string switchName, string[] parameters, string delimiter);
member this.AppendSwitchIfNotNull : string * string[] * string -> unit
Public Sub AppendSwitchIfNotNull (switchName As String, parameters As String(), delimiter As String)

Parameters

switchName
String

The switch to append to the command line, may not be null

parameters
String[]

Switch parameters to append, quoted if necessary. If null, this method has no effect.

delimiter
String

Delimiter to put between individual parameters, may not be null (may be empty)

Examples

AppendSwitchIfNotNull("/sources:", new string[] {"Alpha.cs", "Be ta.cs"}, ";") yields /sources:Alpha.cs;\"Be ta.cs\".

AppendSwitchIfNotNull("/sources:", new string[] {"Alpha.cs", "Be ta.cs"}, ";") => "/sources:Alpha.cs;"Be ta.cs""

Remarks

This method encapsulates individual file names with quotation marks as necessary.

If the command line is not empty, then this method also appends the command line with a space, before the switch.

Applies to

AppendSwitchIfNotNull(String, ITaskItem[], String)

Source:
CommandLineBuilder.cs

Appends a command-line switch that takes a ITaskItem[] parameter, and add double-quotes around the individual filenames if necessary. This method appends a space to the command line (if it's not currently empty) before the switch.

public:
 void AppendSwitchIfNotNull(System::String ^ switchName, cli::array <Microsoft::Build::Framework::ITaskItem ^> ^ parameters, System::String ^ delimiter);
public void AppendSwitchIfNotNull (string switchName, Microsoft.Build.Framework.ITaskItem[] parameters, string delimiter);
member this.AppendSwitchIfNotNull : string * Microsoft.Build.Framework.ITaskItem[] * string -> unit
Public Sub AppendSwitchIfNotNull (switchName As String, parameters As ITaskItem(), delimiter As String)

Parameters

switchName
String

The switch to append to the command line, may not be null

parameters
ITaskItem[]

Switch parameters to append, quoted if necessary. If null, this method has no effect.

delimiter
String

Delimiter to put between individual parameters, may not be null (may be empty)

Examples

See example in AppendSwitchIfNotNull.

See the string[] overload version

Remarks

This method encapsulates individual file names with quotation marks as necessary.

If the command line is not empty, then this method also appends the command line with a space, before the switch.

Applies to

AppendSwitchIfNotNull(String, String)

Source:
CommandLineBuilder.cs

Appends a command-line switch that takes a single string parameter, quoting the parameter if necessary. This method appends a space to the command line (if it's not currently empty) before the switch.

public:
 void AppendSwitchIfNotNull(System::String ^ switchName, System::String ^ parameter);
public void AppendSwitchIfNotNull (string switchName, string parameter);
member this.AppendSwitchIfNotNull : string * string -> unit
Public Sub AppendSwitchIfNotNull (switchName As String, parameter As String)

Parameters

switchName
String

The switch to append to the command line, may not be null

parameter
String

Switch parameter to append, quoted if necessary. If null, this method has no effect.

Examples

AppendSwitchIfNotNull("/source:", "File Name.cs") yields /source:\"File Name.cs\".

AppendSwitchIfNotNull("/source:", "File Name.cs") => "/source:"File Name.cs""

Remarks

This method encapsulates individual file names with quotation marks as necessary.

If the command line is not empty, then this method also appends the command line with a space, before the switch.

Applies to

AppendSwitchIfNotNull(String, ITaskItem)

Source:
CommandLineBuilder.cs

Append a switch [overload] This method appends a space to the command line (if it's not currently empty) before the switch.

public:
 void AppendSwitchIfNotNull(System::String ^ switchName, Microsoft::Build::Framework::ITaskItem ^ parameter);
public void AppendSwitchIfNotNull (string switchName, Microsoft.Build.Framework.ITaskItem parameter);
member this.AppendSwitchIfNotNull : string * Microsoft.Build.Framework.ITaskItem -> unit
Public Sub AppendSwitchIfNotNull (switchName As String, parameter As ITaskItem)

Parameters

switchName
String

The switch to append to the command line, may not be null

parameter
ITaskItem

Switch parameter to append, quoted if necessary. If null, this method has no effect.

Examples

See example in AppendSwitchIfNotNull.

See the string overload version

Remarks

This method encapsulates individual file names with quotation marks as necessary.

If the command line is not empty, then this method also appends the command line with a space, before the switch.

Applies to