views:

270

answers:

1

I have a build script running successfully, but I am having a hard time running anything after aspnet_compiler completes. I want to use robocopy to copy the project to another folder. If I put the copy task above the compile (as shown below) I get the message to the console, but if I place it after the compile it is not seen. Am I missing something? Do I need to check for a return code from the compiler to call tasks after its completion?

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

And yes, when/if I move the copy task below precompile-web I change the depends="precompile-web" and the compile task depends to "init".

A: 

If I understand you correctly here, you want to:

  1. Copy the files
  2. Compile them using MSBuild
  3. Precompile them for the web

Is that right? I would have thought you'd want to do it this way around:

  1. Compile the files using MSBuild
  2. Precompile them for the web
  3. Copy the files somewhere else (for use by IIS, etc)

If my way is correct, then I'd guess you'd want your targets to reference each other like this?

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

This way, you're not pinning each of your targets down to relying upon other targets (for re-use) but you get the order that you need to achieve the job at hand.

Any good to you?

Brett Rigby
Yes I wanted to accomplish what you assumed, the second set of commands. The problem was in the order to which I had them firing. Thanks.
Ryan H