2009-10-05 54 views
1

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

<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' 
     /> 

是的,当/如果我搬到低于预编译的Web副本任务,我改变取决于=“预编译的Web”和编译任务依赖于“初始化”。

回答

1

如果我理解你正确地在这里,你想:

  1. 将文件复制
  2. 编译他们使用的MSBuild
  3. 预编译他们的网络

是这样吗?我本来以为你会想这样做,周围是这样的:

  1. 使用的MSBuild
  2. 预编译他们的网络
  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> 

这样一来,你不是钉住您的每一个目标直至依赖于其他目标(再利用),但你得到你需要实现手头的工作秩序。

对你有好处吗?

+0

是的,我想完成你所设想的第二套命令。问题在于我让他们开火的顺序。谢谢。 – 2010-02-22 15:01:32