In a previous blog post, I explained how to recompile the MsBuild task for SSIS 2016. Now that we’ve this task, we’ll see how to use it.
First,let define a new file (here named
Build.proj) in our SSIS solution
Then, we’ll need to define our headers and namespaces:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="SSISBuild" />
The last attribute
DefaultTargets is defining the part of the xml file that will be used when this file will be executed. In our case we’ll just have one version of the Target but it’s better to already correctly define it.
We also have to specify to MsBuild that an external assembly will be used (the community tasks to build SSIS packages).
<UsingTask TaskName="DeploymentFileCompilerTask" AssemblyFile="..\SSISMSBuild\SSISMSBuild\bin\Debug\SSISMSBuild.dll" />
It’s now time to create a kind of variable to host the name/path of our SSIS project. Within MsBuild you achieve this task by using the following syntax:
<ItemGroup> <SSISProjPath Include="..\anotherFolder\MySSISProject.dtproj" /> </ItemGroup>
SSISProjPath is the name of the variable and the value is defined in the
Now, let’s focus on the
Target itself. The target is named
SSISBuild and will display a message before using the task to compile the SSIS project. The second step is performed by invoking the task
<Target Name="SSISBuild"> <Message Text="*********** Building SSIS project ***********"/> <DeploymentFileCompilerTask InputProject="@(SSISProjPath)" Configuration="Development" ProtectionLevel="DontSaveSensitive" /> </Target>
The first parameter of
DeploymentFileCompilerTask is the name of your project, you can safely use your variable by specifying the
@() syntax. The second parameter is the configuration, personnaly I never change it and use
Development but up-to-you. The
protection level will override the corresponding property of your project.
If you want to compile, your project you can call MsBuild and specify
Build.proj as the parameter, it will do the job! But it’s more interesting if you can include this in your build steps. I’ll just show you how you can include this in your TeamCity configuration:
- Create a build step
- Define the
- Specify the MSBuild property for
Microsoft Build Tools 2015and
- Don’t forget to specify the name of your
Once you’ve this setup in place, you can trigger your TeamCity project to get the following message and your build ready.