【问题标题】:NAnt and ASP.NET CompilerNAnt 和 ASP.NET 编译器
【发布时间】:2009-10-05 18:00:06
【问题描述】:

我有一个成功运行的构建脚本,但是在 aspnet_compiler 完成后我很难运行任何东西。我想使用 robocopy 将项目复制到另一个文件夹。如果我将复制任务放在编译之上(如下所示),我会将消息发送到控制台,但如果我将它放在编译之后,则看不到它。我错过了什么吗?完成后是否需要检查编译器的返回码才能调用任务?

<target name="copy" depends="init">
    <echo message="This is my message for robocopy..."/>
</target>

<target name="compile" depends="copy">
    <exec program="${msbuild.exe}"
          commandline='MySolution.sln /p:Configuration=${Configuration};OutDir="${build.dir}\\"' />
</target>

<target name="precompile-web" depends="compile">
    <exec program="${aspnet_compiler.exe}"
      commandline='-v /MyProj-p "${build.dir}"\_PublishedWebsites\MyProj.Web'
      />

是的,当/如果我将复制任务移动到 precompile-web 下方时,我会更改depends="precompile-web" 并且编译任务取决于“init”。

【问题讨论】:

    标签: asp.net build-automation asp.net-3.5 nant


    【解决方案1】:

    如果我在这里理解正确,您希望:

    1. 复制文件
    2. 使用 MSBuild 编译它们
    3. 为 Web 预编译它们

    对吗?我原以为你会想这样做:

    1. 使用 MSBuild 编译文件
    2. 为 Web 预编译它们
    3. 将文件复制到其他地方(供 IIS 等使用)

    如果我的方法是正确的,那么我猜你希望你的目标像这样相互引用?

    <target name="compile-and-publish" depends="compile,precompile-web,copy" />
    
    <target name="compile"> 
        <exec program="${msbuild.exe}" commandline='MySolution.sln /p:Configuration=${Configuration};OutDir="${build.dir}\\"' /> 
    </target> 
    
    <target name="precompile-web"> 
        <exec program="${aspnet_compiler.exe}" commandline='-v /MyProj-p "${build.dir}"\_PublishedWebsites\MyProj.Web'  /> 
    </target>
    
    <target name="copy" depends="init"> 
        <echo message="This is my message for robocopy..."/> 
    </target>
    

    这样,您不会将每个目标都固定为依赖其他目标(以供重复使用),而是获得完成手头工作所需的顺序。

    对你有好处吗?

    【讨论】:

    • 是的,我想完成你假设的第二组命令。问题在于我让他们开火的顺序。谢谢。
    猜你喜欢
    • 2014-02-08
    • 1970-01-01
    • 2011-09-05
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 2010-09-10
    • 2018-12-06
    • 1970-01-01
    相关资源
    最近更新 更多