Skip to main content

Fully Automate the Biml Expansion

Why This Pattern Matters

Once a metadata-driven Biml project is in place, expanding it manually inside the IDE every time the source schema changes does not scale. Running the Biml expansion from the command line lets the build run on a schedule, in a CI pipeline, or as a post-deploy step that always rebuilds packages from the latest metadata.

The Command-Line Compiler

The BimlStudio installer ships with a command-line compiler executable named 'bimlc.exe' in the installation folder. The compiler accepts a source Biml file and a target directory, then writes the generated packages and projects into the target directory.

The basic syntax is:

bimlc.exe -s="<sourcefile>" -t="<targetfolder>"

The full set of supported switches is documented under the Hadron Compiler Command Line Options topic in the Varigence documentation. The 'hadron' name is a legacy name for the same tool.

A Sample Biml File

The script below reads a list of source tables through a stored procedure call and emits one package per table. The connection strings reference a build server and a build database; substitute environment-specific values when running the example.

<#@ template language="C#" hostspecific="true" #>
<#@ import namespace="System.Data" #>
<#@ import namespace="System.Linq" #>

<# var metaConnString = "Provider=SQLNCLI11;Server=BuildServer;Initial Catalog=BuildMetaDB;Integrated Security=SSPI;"; #>
<#
DataTable tables = ExternalDataAccess.GetDataTable(metaConnString, "[dbo].[GetExtractTableList]");
#>
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<OleDbConnection Name="META" CreateInProject="true"
ConnectionString="Provider=SQLNCLI11;Data Source=BuildServer;Integrated Security=SSPI;Initial Catalog=BuildMetaDB" />
</Connections>
<Packages>
<# foreach(DataRow table in tables.Rows) { #>
<Package Name="Extract <#=table["schema"] #>_<#=table["table"] #>">
</Package>
<# } #>
</Packages>
</Biml>

Running the Compiler

Save the file as 'AutoCompile.biml' and decide where the generated packages should land, for example 'C:\Build\Output'. The command line is:

bimlc.exe -s="C:\Build\AutoCompile.biml" -t="C:\Build\Output"

Pressing Enter runs the compiler, which prints progress to the console. The summary line reports how many packages and projects were created. Each generated package lands inside its own project folder under the target directory.

Where to Take It Next

Wrapping the command in a scheduled job, an MSBuild target, or a CI step turns Biml expansion into a fully unattended step. When the source metadata changes, the build picks up the change and produces a fresh set of packages without anyone opening the IDE.