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.

C#
public void AppendSwitchIfNotNull(string switchName, string[] parameters, string delimiter);

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

.NET Framework 4.8.1 e outras versións
Produto Versións
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public void AppendSwitchIfNotNull(string switchName, Microsoft.Build.Framework.ITaskItem[] parameters, string delimiter);

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

.NET Framework 4.8.1 e outras versións
Produto Versións
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public void AppendSwitchIfNotNull(string switchName, string parameter);

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

.NET Framework 4.8.1 e outras versións
Produto Versións
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public void AppendSwitchIfNotNull(string switchName, Microsoft.Build.Framework.ITaskItem parameter);

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

.NET Framework 4.8.1 e outras versións
Produto Versións
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1