You have to find the actual asset you want to build from. example:
var buildSettings = (BuildConfiguration)AssetDatabase.LoadAssetAtPath("Packages/com.thelebaron.BuildTools/game.buildconfiguration", typeof(BuildConfiguration));
//Assert.IsNotNull(buildSettings);
buildSettings.Build();
The path should be wherever your particular BuildConfiguration resides in your project. I happen to have mine in a package folder but it can be inside your assets folder.