TextString ClassMSBuild Extension Pack Help 4.0.12.0
Valid TaskActions are:

Compare (Required: String1, String2, Comparison Optional: IgnoreCase Output: Result)

EndsWith (Required: String1, String2 Optional: IgnoreCase Output: Result)

Format (Required: String1, Strings Output: NewString)

GetLength (Required: OldString Output: NewString)

Insert (Required: OldString, String1, StartIndex Output: NewString)

PadLeft (Required: OldString, String1 (1 char) Optional: Count Output: NewString)

PadRight (Required: OldString, String1 (1 char) Optional: Count Output: NewString)

Remove (Required: OldString, StartIndex Optional: Count Output: NewString)

Replace (Required: OldString, OldValue, NewValue Output: NewString)

Split (Required: String1, String2 Optional: StartIndex Output: Strings, NewString)

StartsWith (Required: String1, String2 Optional: IgnoreCase Output: Result)

Substring (Required: OldString Optional: StartIndex, Count Output: NewString)

ToLower (Required: OldString Output: NewString)

ToUpper (Required: OldString Output: NewString)

Trim (Required: OldString Output: NewString)

Remote Execution Support: NA

Inheritance Hierarchy

SystemObject
  Microsoft.Build.UtilitiesTask
    MSBuild.ExtensionPackBaseTask
      MSBuild.ExtensionPack.FrameworkTextString

Namespace: MSBuild.ExtensionPack.Framework
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0

The TextString type exposes the following members.

Constructors

  NameDescription
Public methodTextString
Top
Properties

  NameDescription
Public propertyComparison
Sets the Comparison. Supports 'GreaterThan', 'LessThan', 'GreaterThanOrEquals', 'LessThanOrEquals', 'Contains', 'StartsWith', 'EndsWith'
Public propertyCount
Sets the count
Public propertyIgnoreCase
Sets a value indicating whether [ignore case]. Default is true.
Public propertyNewString
Gets the new string.
Public propertyNewValue
Sets the new value.
Public propertyOldString
Sets the old string.
Public propertyOldValue
Sets the old value.
Public propertyResult
Gets a value indicating whether the result is true or false.
Public propertyStartIndex
Sets the start index for Remove
Public propertyString1
Sets the string1.
Public propertyString2
Sets the string2.
Public propertyStrings
Top
Examples

<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <Target Name="Default">
        <!-- Format a string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Format" String1="{0}.{1}.{2}.{3}" Strings="3;5;4;0">
            <Output TaskParameter="NewString" PropertyName="val"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="Format Result: $(val)"/>
        <!-- Split a string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Split" String1="Hello;how;are;you" String2=";">
            <Output ItemName="out" TaskParameter="Strings"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: %(Out.Identity)"/>
        <!-- Split another string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Split" String1="HelloMIKEhowMIKEareMIKeyou" String2="MIKE">
            <Output ItemName="out" TaskParameter="Strings"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: %(Out.Identity)"/>
        <!-- Uppercase a string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="ToUpper" OldString="helLo">
            <Output PropertyName="out" TaskParameter="NewString"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(out)"/>
        <!-- Lowercase a string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="ToLower" OldString="HellO">
            <Output PropertyName="out" TaskParameter="NewString"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(out)"/>
        <!-- PadLeft a string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="PadLeft" OldString="Hello" String1="A" Count="10">
            <Output PropertyName="out" TaskParameter="NewString"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(out)"/>
        <!-- PadRight a string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="PadRight" OldString="Hello" String1="A" Count="10">
            <Output PropertyName="out" TaskParameter="NewString"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(out)"/>
        <!-- Check whether a string starts with another string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="Hello" String2="He">
            <Output PropertyName="TheResult" TaskParameter="Result"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(TheResult)"/>
        <!-- Check whether a string ends with another string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="EndsWith" String1="Hello" String2="Lo" IgnoreCase="false">
            <Output PropertyName="TheResult" TaskParameter="Result"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(TheResult)"/>
        <!-- Compare two strings to see whether they are equal -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Compare" String1="Hello" String2="Hello" Comparison="equals">
            <Output PropertyName="TheResult" TaskParameter="Result"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(TheResult)"/>
        <!-- Compare two strings to see whether they are equal -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Compare" String1="Hello" String2="Hallo" Comparison="equals">
            <Output PropertyName="TheResult" TaskParameter="Result"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(TheResult)"/>
        <!-- See whether one string is greater than another -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Compare" String1="Hello" String2="Hallo" Comparison="greaterthan">
            <Output PropertyName="TheResult" TaskParameter="Result"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(TheResult)"/>
        <!-- See whether one string is less than another -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Compare" String1="Hello" String2="Hallo" Comparison="lessthan">
            <Output PropertyName="TheResult" TaskParameter="Result"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(TheResult)"/>
        <!-- See whether a string contains another string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Compare" String1="Hello" String2="llo" Comparison="contains">
            <Output PropertyName="TheResult" TaskParameter="Result"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(TheResult)"/>
        <!-- Replace the contents of a string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Replace" OldString="Hello" OldValue="llo" NewValue="XYZ">
            <Output PropertyName="out" TaskParameter="NewString"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(out)"/>
        <!-- Substring the contents of a string -->
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="Substring" OldString="Hello" StartIndex="1" Count="2">
            <Output PropertyName="out" TaskParameter="NewString"/>
        </MSBuild.ExtensionPack.Framework.TextString>
        <Message Text="The Result: $(out)"/>
    </Target>
</Project>
See Also

Reference