简体   繁体   English

如何在TFS和SSIS中使用MSBuild

[英]How to use MSBuild with TFS and SSIS

I'm a complete novice in using TFS Build definition and MSBuild scripts. 我是使用TFS Build定义和MSBuild脚本的完全新手。

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. 我想自动化我的SSIS构建和部署,并创建一个构建定义,该构建定义将在我排队时立即构建和部署SSIS项目。

I found this project: http://sqlsrvintegrationsrv.codeplex.com/releases/view/82369 我找到了这个项目: 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 它允许您创建一个可以放置在C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\PrivateAssemblies的DLL

Then you can call the SSIS.MSBuild.proj (See end for this) with certain parameters like this in a visual studio command line: 然后,您可以在Visual Studio命令行中使用诸如此类的某些参数调用SSIS.MSBuild.proj(请参见结尾):

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: 或者我可以将其放在BAT文件中,如下所示:

%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. 当您运行BAT文件时,它工作正常,它会构建和部署SSIS项目。

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? 我如何使用它使其自动化,以便可以在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. 例如,我们具有针对DEV,SIT,SYS,UAT,PRD的SSIS配置。 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? 以某种方式使用Powershell有什么用吗?

Here is SSIS.MSBuild.proj: 这是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. 编辑我尝试将一些MSBuild参数添加到TFS构建定义中。 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"

I think you are prety close about the solution. 我认为您对解决方案非常了解。 you can call your package in console application and set the variables there. 您可以在控制台应用程序中调用程序包并在其中设置变量。 And for different DEV, SIT, SYS, UAT, PRD. 对于不同的DEV,SIT,SYS,UAT,PRD。 you can have configuration file for the the console application. 您可以拥有控制台应用程序的配置文件。 and then you can set the package variables in the console app. 然后您可以在控制台应用程序中设置程序包变量。 I hope it solve the preoblem. 我希望它解决了这个障碍。 As much i could understand. 据我所知。

Please let me know if this is not related to your problem then explain your question a bit more. 如果这与您的问题无关,请告诉我,然后再多解释一下您的问题。

To answer your question, the best way would be to use an UpgradeBuildTemplate for your team build. 要回答您的问题,最好的方法是为团队构建使用UpgradeBuildTemplate。

Modify the build script to calls the tasks that you have created in the "AfterCompile" target of the build. 修改生成脚本以调用在生成的“ AfterCompile”目标中创建的任务。 See below 见下文

http://msdn.microsoft.com/en-us/library/aa337604(v=vs.100).aspx http://msdn.microsoft.com/zh-CN/library/aa337604(v=vs.100).aspx

You can pass build parameters in your team build definition. 您可以在团队构建定义中传递构建参数。 If you edit your build definition and edit Process, you will see option to pass MSBuild Arguments. 如果您编辑构建定义并编辑过程,您将看到传递MSBuild参数的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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