Create a package to call all existing packages

gravatar

Scott Currie

Create a package that executes all DTSX files in a given directory.

published 12.17.13

last updated 12.17.13


Share

                            


<# var projectRootEnvVar = System.Environment.GetEnvironmentVariable("PROJECT_ROOT"); #>
<# var sourceDirectory = string.IsNullOrEmpty(projectRootEnvVar) ? @"C:\Path\Where\Packages\Live" : projectRootEnvVar;#>
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
  <Packages>
    <Package Name="Execute All Non-Biml Packages" ConstraintMode="Parallel">
      <Tasks>
        <# foreach (var filePath in System.IO.Directory.GetFiles(sourceDirectory, "*.dtsx", System.IO.SearchOption.AllDirectories)) { #>
        <ExecutePackage Name="Run <#=filePath#>">
          <ExternalFile ExternalFilePath="<#=filePath#>" />
        </ExecutePackage>
		<# } #>
      </Tasks>
    </Package>
  </Packages>
</Biml>
                        

In this sample, we iterate over all of the DTSX files in a given directory (and all subdirectories). We then create an ExecutePackage task to execute each of them. Note that if you don't want to do a recursive directory search, you can instead use System.IO.SearchOption.TopDirectoryOnly in the GetFiles method call.

In case your team has differing file system layouts, we have also provided a check for the "PROJECT_ROOT" environment variable. If present, it uses the value of the environment variable as the search folder. If not present, it falls back to a default hard-coded folder. Remember that if you are setting the environment variable for the first time, you may need to restart BIDS/SSDT or Mist to ensure that the variable is being picked up.

You are not authorized to comment. A verification email has been sent to your email address. Please verify your account.

Comments

gravatar

Hector1

8:01am 05.09.16

Hello. I am trying to get this but i get an error. I attach images. [IMG]http://i63.tinypic.com/14w6igx.jpg[/IMG] [IMG]http://i64.tinypic.com/22alb4.jpg[/IMG]