【问题标题】:Putting together a multiproject build script组合一个多项目构建脚本
【发布时间】:2012-06-04 12:13:29
【问题描述】:

我是构建脚本的新手,需要一些帮助来为多项目解决方案编写脚本。我目前只有一个项目,但我需要包含其他项目,包括我的测试项目,这样我才能以正确的顺序成功构建它们。

1) 如何在脚本中指定编译顺序? 2)您如何按顺序将项目组合在一起以进行构建? 3) 在为生产进行构建时,您是构建解决方案文件还是只构建单个项目? 4) 构建脚本真的有必要吗(尤其是当您使用像 Visual Studio 这样的工具并且没有外部资源时)?

<?xml version="1.0"?>
<project name="Access Report Build Script" default="build" basedir=".">
    <description>Project Build File.</description>
    <property name="debug" value="true" overwrite="false" />
    <property name="fileName" value="BReportSuite" overwrite="false" />
    <property name="Main" value="BReportMain" overwrite="false" />
    <property name="ReportDisplay" value="BReportDisplay" overwrite="false" />
    <property name="ReportRecord" value="BReportRecord" overwrite="false" />
    <property name="ReportAccount" value="BReportAccount" overwrite="false" />

    <target name="clean" description="clean up generated files">
        <delete file="${fileName}.exe" failonerror="false" />
        <delete file="${fileName}.pdb" failonerror="false" />
    </target>

    <target name="build" description="compile source">
        <echo message="${fileName}"  />
        <csc target="exe" output="${fileName}.exe" debug="${debug}">
            <sources>
                <include name="${fileName}.cs" />
                <include name="${ReportDisplay}.cs" />
                <include name="${ReportRecord}.cs" />
                <include name="${ReportAccount}.cs" />
            </sources>
        </csc>
    </target>
    </project>

【问题讨论】:

标签: c# visual-studio-2010 msbuild nant


【解决方案1】:

当您想要自动化事情时,构建脚本会派上用场。

例如,如果您想使用 Continues Integration,您希望每次有人签入新代码时都构建您的代码。这不能通过启动 Visual Studio 并手动执行构建来完成。 同样对于部署场景,必须有一个自动化脚本。您不希望部署过程中的手动步骤会被遗忘。

最简单的做法是使用一个解决方案文件来指定要构建的项目。如果您使用必要的项目和参考对其进行配置并指定要部署的配置(例如发布或暂存),您可以在 Visual Studio 中配置很多设置。

【讨论】:

  • 您能否给我一个资源来帮助我完成此任务,我的意思是使用解决方案文件,并使用必要的对象和引用对其进行配置。
  • 为构建项目使用解决方案文件与现在在 Visual Studio 中使用它们的方式没有什么不同。下面是关于 MSBuild msdn.microsoft.com/en-us/library/ms164311.aspx 的一些信息,如果您查看页面末尾,您会看到使用 sln 文件作为参数。
猜你喜欢
  • 2023-03-21
  • 2021-03-31
  • 2014-05-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-30
  • 1970-01-01
  • 2020-03-03
相关资源
最近更新 更多