简体   繁体   中英

How to use MSBuild with TFS for SSIS Build

I want to automate my SSIS build and deployments and create a build definition which will build and deploy my SSIS project whenever I queue it up.

I found this project: http://sqlsrvintegrationsrv.codeplex.com/releases/view/82369

which allows you to create a DLL which you can place in C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\PrivateAssemblies

Then you can call the SSIS.MSBuild.proj (See end for this) with certain parameters like this in a visual studio command line:

MSBuild SSIS.MSBuild.proj /t:SSISBuild,SSISDeploy /p:SSISProj="MySSISProject",Configuration="DEV",,SSISServer="AB-CDE-FGH-I1\DEV",ProjectName="MySSISProject"

or I can put it in a BAT file like this:

%systemroot%\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe SSIS.MSBuild.proj /t:SSISBuild,SSISDeploy /p:SSISProj="MySSISProject",Configuration="DEV",,SSISServer="AB-CDE-FGH-I1\DEV",ProjectName="MySSISProject"

It works fine when you run the BAT file, it builds and deploys the SSIS project.

Questions:

  1. How can I use this so it is automated, so I can manually kick off a build and deployment from within VS/TFS? Using a build definition.

  2. How can I ensure the correct configurations are selected, and the correct destination server? For example we have SSIS configurations for DEV, SIT, SYS, UAT, PRD. Each with its own server name. Do I need a separate build definition for each environment or is there a way to use one build definition?

  3. Anything useful in using powershell somehow?

Here is SSIS.MSBuild.proj:

<?xml version="1.0" encoding="Windows-1252"?>
<Project  xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
          DefaultTargets="SSISBuild;SSISDeploy">
  <!--Requires a property called $(SSISProj) to be defined when this script is called-->
  <UsingTask TaskName="DeploymentFileCompilerTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll" />
  <Target Name="SSISBuild" Condition="'$(SSISProj)' != ''">
    <PropertyGroup>
      <SSISProjPath>$(SSISProj)\$(SSISProj).dtproj</SSISProjPath>
    </PropertyGroup>
    <Message Text="**************Building SSIS project: $(SSISProjPath) for configuration: $(CONFIGURATION)**************" />
    <DeploymentFileCompilerTask
      InputProject="$(SSISProjPath)"
      Configuration="$(CONFIGURATION)"
      ProtectionLevel="DontSaveSensitive">
    </DeploymentFileCompilerTask>
  </Target>

  <UsingTask TaskName="DeployProjectToCatalogTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll" />
  <Target Name="SSISDeploy" Condition="'$(SSISProj)' != ''">
    <Message Text="**************Publishing SSIS project: $(SSISProj) to: $(SSISServer) to folder: $(PROJECTNAME)**************" />
    <PropertyGroup>
      <ISPac>$(SSISProj)\bin\$(CONFIGURATION)\$(SSISProj).ispac</ISPac>
    </PropertyGroup>
    <DeployProjectToCatalogTask
          DeploymentFile="$(ISPac)"
          Instance="$(SSISServer)"
          Folder="$(PROJECTNAME)"
          CreateFolder="true"/>
  </Target>
</Project>

EDIT I tried adding some MSBuild Arguments to the TFS Build Definition. I tried various combinations of arguments, some with quotes, some without. I couldn't get it to work.

"C:\Users\me\Desktop\Buildssis\SSIS.MSBuild.proj" /t:SSISBuild,SSISDeploy /p:SSISProj="MySSISProject",Configuration="SIT",SSISServer="AB-CDE-FGH-I1\DEV",ProjectName="MySSISProject"

But I always get this error:

MSBUILD : error MSB1008: Only one project can be specified.
Switch: C:\Users\me\Desktop\Buildssis\SSIS.MSBuild.proj

For switch syntax, type "MSBuild /help"

Regarding the MSBUILD error, in the process section of your build definition:

  • the path to the proj file goes into the section "2. Build > 1. Projects"
  • the MSBUILD switches go in the field named "2. Build > 5. Advanced > MSBUILD Arguments".

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM