如何让 MSBuild 处理所有 SSIS 项目 [英] How to have MSBuild process all SSIS projects

查看:70
本文介绍了如何让 MSBuild 处理所有 SSIS 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功关注博客 1 让 MSBuild 构建 SSIS 项目.这涉及创建一个 dll 和一个 MSBuild 脚本.该过程适用于任何单个项目文件.

I have successfully followed the blog 1 to get MSBuild to build an SSIS project. This involved creating a dll and an MSBuild script. The process works correctly for any single project file.

我正在寻求帮助,使此过程适用于解决方案 (.sln) 文件中定义的每个 .dtproj 文件.我已阅读有关 MSBuild 批处理 2 但它指的是已定义的项目在构建脚本中.我希望它适用于解决方案文件中的任何项目,这样我就不必在每次添加/删除/移动项目时手动编辑脚本.

I'm looking for help in getting this process to work for each .dtproj file that is defined in a solution (.sln) file. I have read about MSBuild Batching 2 but it refers to items that are defined in the build script. I want it to work with whatever projects are in the solution file so I don't have to manually edit a script every time a project is add/removed/moved.

任何建议或方法链接?感谢您花时间阅读我的问题!

Any suggestions or links to approaches? Thanks for taking the time to read my question!

博客

MSBuild 批处理

推荐答案

如果您不想使用批处理选项,您可以尝试以下操作:

If you don't want to with the batch option you can try something like this:

<Project  xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
          DefaultTargets="Build">

  <PropertyGroup>
    <MySolution Condition="'$(MySolution)'==''">MySolution.sln</MySolution>
    <Configuration Condition="'$(Configuration)'==''">Release</Configuration>
    <SSISServer Condition="'$(SSISServer)'==''">MyServer</SSISServer>
    <PROJECTNAME Condition="'$(PROJECTNAME)'==''">MyProjectName</PROJECTNAME>
  </PropertyGroup>

  <UsingTask TaskName="DeploymentFileCompilerTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll" />
  <UsingTask TaskName="DeployProjectToCatalogTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll" />
  
  <Import Condition="Exists('$(MySolution).metaproj')" Project="$(MySolution).metaproj"/>
  
  <Target Name="Initialize">
    <MSBuild Projects="$(MySolution)" Properties="Configuration=$(Configuration);MSBuildEmitSolution=1" Targets="Clean" />
  </Target>
  
  <Target Name="Build">
    <Message Text="**************Building SSIS project: %(ProjectReference.FullPath) for configuration: $(Configuration)**************" />
    <DeploymentFileCompilerTask
        InputProject="%(ProjectReference.FullPath)"
        Configuration="$(CONFIGURATION)"
        ProtectionLevel="DontSaveSensitive">
    </DeploymentFileCompilerTask>
  </Target>

  <Target Name="Deploy">
    <Message Text="**************Deploying SSIS project: %(ProjectReference.FullPath) for configuration: $(Configuration)**************" />
    <Message Text="..\%(ProjectReference.RootDir)%(ProjectReference.Directory)\bin\$(CONFIGURATION)\%(ProjectReference.FileName)%(ProjectReference.Extension).ispac"/>

    <DeployProjectToCatalogTask
        DeploymentFile="..\%(ProjectReference.RootDir)%(ProjectReference.Directory)\bin\$(CONFIGURATION)\%(ProjectReference.FileName)%(ProjectReference.Extension).ispac"
        Instance="$(SSISServer)"
        Folder="$(PROJECTNAME)"
        CreateFolder="true"/>
  </Target>
</Project>

这将生成解决方案的 MsBuild 项目版本,包括所有包含的项目(阅读有关 msbuildemitsolution 的信息),之后它将导入生成的msbuild 解决方案".(.metaproj) 并使用 ProjectReference 项使用DeploymentFileCompilerTask"将它们一一执行.和DeployProjectToCatalogTask"

This will generate a MsBuild project version of the solution including all the included projects (read about msbuildemitsolution), after that it will import the generated "msbuild solution" (.metaproj) and use the ProjectReference items to execute them one by one using the "DeploymentFileCompilerTask" and "DeployProjectToCatalogTask"

你可以这样称呼它:

对于构建:

msbuild SSIS.proj/t:Initialize

msbuild SSIS.proj /t:Initialize

msbuild SSIS.proj/t:Build

msbuild SSIS.proj /t:Build

用于部署:

msbuild SSIS.proj/t:Initialize

msbuild SSIS.proj /t:Initialize

msbuild SSIS.proj/t:Deploy

msbuild SSIS.proj /t:Deploy

Initialize 目标将生成msbuild 解决方案";并且您需要调用此目标以确保内容更新.

The Initialize target will generate the "msbuild solution" and you need to call this target to ensure the content is updated.

您可以在命令行中传递开头定义的任何属性,以将脚本用于不同的解决方案.

You can pass any of the Properties defined at the beginning on the command line to use the script for different solutions.

如果您需要不同的文件夹"对于每个项目,您可以使用文件名"项目元数据(即 %(ProjectReference.Filename) 而不是 $(PROJECTNAME)).

If you need different "Folders" for each project, you could use the "Filename" item metadata (i.e. %(ProjectReference.Filename) instead of $(PROJECTNAME)).

注意:这不是最终的工作脚本,但如果您对DeploymentFileCompilerTask"进行评论,它应该清楚地说明建议的解决方案.和DeployProjectToCatalogTask"您可以执行脚本的节点并在控制台中看到一些消息以及将要处理的数据.

Note: This is not a final working script, but it should give a clear idea of the proposed solution, if you comment the "DeploymentFileCompilerTask" and "DeployProjectToCatalogTask" nodes of the script you can execute it and see some messages in the console with the data that will be processed.

这篇关于如何让 MSBuild 处理所有 SSIS 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆