如何首先使用msbuild构建依赖项目 [英] How to build dependent project first with msbuild

查看:100
本文介绍了如何首先使用msbuild构建依赖项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始研究msbuild,因为我想创建自己的构建脚本.现在,我能够创建仅编译一个项目的构建脚本,但是我该如何处理依赖关系?

I have just started looking into msbuild, because I want to make my own build scripts. For now I am able to create build scripts that compiles only one project, but how do I handle dependencies?

例如,如果我有两个用这两个msbuild脚本构建的项目怎么办?

For example what if I have two projects that gets build with these two msbuild scripts?

  1. projectA.xml
  2. projectB.xml

如何告诉msbuild在执行projectB.xml时应首先执行projectA.xml?

How do I tell msbuild that when I am executing projectB.xml that it should first execute projectA.xml?

我对此进行了很多搜索,但是似乎没有像我这样的入门者能理解的任何东西.我会很高兴链接到描述此文章的链接,或者仅仅是一个小的代码示例.

I have googled alot on this, but it does not seem to get anything that a starter like me understands. I would be more than happy with a link to an article describing this, or maybe just a small code example.

之所以需要此控件,是因为我正在构建一个库.该库由几个项目组成.开发人员应该能够拉出该库的源代码,并仅构建他想要的库.

The reason why I want this control is because of a library I am building. The library consists of several projects. A developer should be able to pull the source code for the library down and build only the libraries that he wants.

实际上,我希望能够从不同的项目构建.net模块.这就是为什么我希望能够运行自定义的msbuild脚本的原因.

Actually I want to be able to build .net modules from the different projects. That is why I want to be able to run a customized msbuild script.

推荐答案

我设置了构建脚本,以便有一些不执行任何操作的常见目标,但是使用了 DependsOnTargets 来设置项目依赖项并运行构建.

I setup my build scripts so that I have a few common targets that do not do anything, but use DependsOnTargets to setup project dependencies and run the build.

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

  <!-- ************************************************************************************************ -->
  <!-- Targets that run the builds -->
  <!-- ************************************************************************************************ -->
  <Target Name="AutoBuild" DependsOnTargets="BuildProject1;BuildProject2;BuildInstallers">
    <OnError ExecuteTargets="NotifyFailure" />
  </Target>
  <Target Name="FullCompile" DependsOnTargets="BuildProject1;BuildProject2">
    <OnError ExecuteTargets="NotifyFailure" />
  </Target>

  <!-- Build Project 1 -->
  <Target Name="BuildProject1">
    <!-- Use MSBuild task and point it to build project1.csproj, project1.sln or whatever your projects is -->
  </Target>

  <!-- Build Project 2 -->
  <Target Name="BuildProject2">
    <!-- Use MSBuild task and point it to build project2.csproj, project2.sln or whatever your projects is -->
  </Target>

  <Target Name="BuildInstallers">
    <!-- Whatever logic you have for building installers -->
  </Target>

</Project>

这篇关于如何首先使用msbuild构建依赖项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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