NAnt 和 ASP.NET 编译器

发布于 2024-08-06 23:24:47 字数 810 浏览 2 评论 0原文

我有一个构建脚本成功运行,但在 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 下面时,我会更改 dependent="precompile-web" 并且编译任务取决于“init”。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贩梦商人 2024-08-13 23:24:47

如果我在这里理解正确的话,您想要:

  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>

这样,您就不会将每个目标都依赖于其他目标(以便重复使用),而是获得完成手头工作所需的命令。

对你有什么好处吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文