Run Multiple Biml Scripts
Use this BimlScript to run every BimlScript in a directory that matches a file pattern, with self-exclusion to prevent infinite recursion. It is the recipe behind a "run all my validation scripts" button in larger Biml solutions.
A common pattern is to author validation BimlScripts (prefixed with 'Val_') that perform programmatic checks across a project, such as verifying naming conventions, ensuring expressions are used on dynamic elements, and asserting that required annotations are present, then emit the results as comments. Wiring them into a single dispatcher script like this one means every check runs in a single Preview action, which keeps the validation pass fast and consistent.
The script reads the validation directory from the 'BFG_BI_EDW3_TRUNK' environment variable (adjust this for your environment), enumerates files matching the 'Val_*' pattern, calls 'CallBimlScript' on each one, and inlines the result as an XML comment so you can scan all warnings in one place.
<#
/*=============================================================================
Description:
Run all Validation Biml Scripts. This is used to have a single place to run
all of our standard checks.
=============================================================================*/
#>
<#@ template language="C#" #>
<#@ import namespace="System.IO" #>
<#@ annotation annotationtype="Description" tag="Summary" text="VERIFY REQUIRED. Runs all Validations (Biml Scripts prefixed with 'Val_')." #>
<#
string edw3Trunk = Environment.GetEnvironmentVariable("BFG_BI_EDW3_TRUNK");
string bimlScriptsDirectory = Path.Combine(edw3Trunk, "Framework", "BimlScripts");
foreach (var file in Directory.GetFiles(bimlScriptsDirectory, "Val_*"))
{
// Skip it if the file is this script (causes infinite recursion)
if(file.ToLowerInvariant().Contains("val_p_project_previewallvalidationscripts.biml")) { continue; }
WriteLine("<!--\nExecuting '{0}'\n{1}\n-->", file, string.Empty.PadRight(80, '='));
var result = CallBimlScript(file);
WriteLine("{0}\n\n", result.Trim());
}
#>
<Biml></Biml>
Submitted by David Darden.