vsSolutionBuildEvent uses SobaScript starting from 1.14. Part of the documentation may be irrelevant. Please update me. |
SBE-Scripts
Togehter with E-MSBuild provides powerful conditions, subcommands, I/O operations, and others.
One of the main features of the language is the processing of only specified language constructs in the main data stream, for example,
some regular data here, except #[var isGit = #[IO cmd("git rev-parse 2>&1")]]
or here #[File get(".version")]
but
#[var revBuild = #[$(
[System.TimeSpan]::FromTicks('$(
[MSBuild]::Subtract($(tNow), $(tBase))
)')
.TotalMinutes.ToString('0')
)]]
also here #[var FirstName]
and here #[File write("packages/__checked"): ]
anything and everything, there is a comment here,
except for the language constructs you see above.
Components
BoxComponent | Container of data for operations like a template, repeating, etc. |
BuildComponent | Managing of build process at runtime. And similar operations for projects and solution. |
CommentComponent | An additional boxed comments for scripts. |
ConditionComponent | Conditional statements for scripts. |
DteComponent | Working with an EnvDTE |
FileComponent | I/O File operations. |
FunctionComponent | Mixed supported functions. |
InternalComponent | The plugin and its operations related to events and actions. |
MSBuildComponent | Advanced evaluation with MSBuild engine. |
NuGetComponent | Support of NuGet packages. |
OWPComponent | Works with OWP and similar operations. |
SevenZipComponent | 7-Zip File archiver with high compression ratio. |
TryComponent | Protects from errors in try{...} block and handles it in catch{...} |
UserVariableComponent | Support of dynamic variables via User-Variables core. |
Syntax
All commands and operations should be wrapped with container:
#[ ... ]
To escape an sequences use #
:
##[ ... ]
Sample
#["
#SobaScript in action
"]
just a regular text between
#[$(v = 1.2.3)]
#[$(log = "$(TMP)/v.txt")]
#[($(Configuration) ~= Deb || true)
{
#[var tBase = $([System.DateTime]::Parse('2019/08/01').ToBinary())]
#[var tNow = $([System.DateTime]::UtcNow.Ticks)]
#[var revBuild = #[$(
[System.TimeSpan]::FromTicks('$(
[MSBuild]::Subtract(
$(tNow),
$(tBase))
)')
.TotalMinutes
.ToString('0')
)]]
#[var v = $(v).$([MSBuild]::Modulo($(revBuild), $([System.Math]::Pow(2, 14))))]
}]
#[var v = $([System.String]::Format("v{0}\r\n\t", $(v)))]
#[try
{
#[File write("#[var log]"):> Example #[var v] Generated by a vsSolutionBuildEvent]
#[IO scall("notepad", "#[var log]")]
}
catch(err, msg)
{
$(err) - Type of Exception
$(msg) - Error Message
}]
#[var tplProps =
<Project>
<PropertyGroup>
<Version>$v</Version>
</PropertyGroup>
</Project>]
#[$(_tprjs = 'E-MSBuild;LSender;SobaScript;SobaScript.Mapper;SobaScript.Z.Core;SobaScript.Z.Ext;SobaScript.Z.VS;Varhead')]
#[$(loop = true)]
#[Box iterate(i = 0; $(loop); i += 1): #[try
{
#[$(_p = "$(_tprjs.Split(';')[$(i)].Trim())")]
#[try
{
#[( $(_p) != "" )
{
#[File write("$(incModules)/$(_p)/.props.user"): #[$(tplProps.Replace('$v', '#[File get("$(_p)/.version")]'))]]
}]
}
catch(err, msg){ #[IO writeLine(STDERR): Cfg .props.user failed: #[$(msg)] ] }]
}
catch { $(loop = false) }] ]
Arguments
Information for this section is not complete or temporarily is not available. To fix it, click - Edit |
type | description |
---|---|
integer | Signed 32-bit integer |
string | From double quotes & From single quotes |
char | |
float | Signed floating-point number with single-precision. The f postfix for clarify: 1.25f, -1.25f |
double | Signed floating-point number with double-precision. The optional d postfix for clarify: 1.25d or simply 1.25, -1.25 |
enum | |
const | |
expression | The composite definition, like a conditional expression ~ (((1 < 2) && true) || $(debug) != "r200") etc. |
Object type
The object type is new type for work with complex mixed data. Initially it was implemented special for vsCommandEvent.
The vsSBE users should see this starting with v0.12.5+
Value can be from all available scalar types + complex, like this:
{}
{"str", true}
{"str", {1, 'y', {-12.457f}}, true}
etc.
Boolean type
Allowed forms:
true | false |
---|---|
1 | 0 |
True | False |
TRUE | FALSE |
true | false |
In (Input) type
This is the unspecified or mixed data. Used as defined and the engine will consider it 'as is':
- May contain any count of newline symbols.
- As and for string arguments may contain other inner sbe-scripts containers that will be evaluated before.
It's also safe for pair symbols of container ([
, ]
). For unpaired it will be corrupt. Therefore, you should place your data inside quote symbols as a string argument above or use special marker (v0.12.6+):
<#data> ... </#data>
Dom & Code Completion
With latest versions we use Dom for inspecting model of SBE-Scripts core. You can see all available features with code completion (Intellisense) in editor.
Work from other Modes
The all available modes should provide support of this engine. Moreover, in C# Mode you can also use engine directly as you want! But first read this.