Tricks with strings

Some additional custom tricks of common operations with strings -> Operations with strings

v0.12.6+ Allows evaluation of string arguments with MSBuild engine in File/Function/BuildComponent + some newer. You can also use the MSBuildComponent to force evaluation if still needed.

Did you know: v0.12.10+ has multiline support for MSBuild expressions via MSBuildComponent:

#[$(
    [System.Math]::Exp('$(
        [MSBuild]::Multiply(
            $([System.Math]::Log(10)), 
            4
        ))'
    )
)]

Did you know: The UserVariableComponent allows the multiline mixed definition:

#[var arg = cd \"D:/tmp/\" 
dir
cd ..
dir]

#[var arg = $(arg.Replace("\r\n", " & "))]

The evaluated value of arg variable above will be as cd \"D:/tmp/\" & dir & cd .. & dir

You can also automatically escape the " (double quotes), erase the first & last the newline symbols etc., for example:

#[var arg = 
cd "D:/tmp/" 
dir
cd ..
dir
]
$(arg.Trim("\r\n").Replace('"', '\"').Replace("\r\n", " & "))
#[var arg = 

cd "#[var pDir]bin/#[var cfg]/"
xcopy *.dll "#[var nupCIMdir]\bin" /Y/R/I
xcopy NLog.dll.nlog "#[var nupCIMdir]\bin" /Y/R/I

]

#[var arg = $(arg.Trim("\r\n").Replace('"', '\"').Replace("\r\n", " & "))]
#[File cmd("#[var arg]")]