将多项目构建脚本放在一起

本文关键字:在一起 脚本 构建 项目 | 更新日期: 2023-09-27 18:36:16

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

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>

将多项目构建脚本放在一起

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

例如,如果要使用"继续集成",则希望在每次有人签入新代码时生成代码。这不能通过启动Visual Studio并手动执行构建来完成。同样对于部署方案,必须使用自动化脚本。您不希望部署过程中的手动步骤被遗忘。

最简单的方法是使用指定要生成的项目的解决方案文件。如果使用必要的项目和引用对其进行配置,并指定要部署的配置(例如发布或暂存),则可以在 Visual Studio 中配置许多设置。