【问题标题】:MSBuild exec task with forMSBuild exec 任务与 for
【发布时间】:2009-02-25 09:10:56
【问题描述】:

我正在尝试将以下命令作为 MSBuild 脚本的一部分运行:

for /R . %f in (*.targets) do copy /Y "%f" "C:\Program Files (x86)\MSBuild\Microso
ft\VisualStudio\TeamBuild"

命令在 exec 中通过以下方式实现:

<Exec WorkingDirectory="$(SolutionRoot)" Command="for /R . %f in (*.targets) do copy /Y &quot;%f&quot; &quot;$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild&quot;" />

该命令在控制台上运行良好,但在尝试从 MSBuild 运行它时出现错误:

Task "Exec"
  Command:
  for /R . %f in (*.targets) do copy /Y "%f" "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild"
  f" "C:\Program was unexpected at this time.
C:\Users\rd-build\AppData\Local\Temp\OH Test2\Continuous.BuildTargets\BuildType\TFSBuild.proj(98,5): error MSB3073: The command "for /R . %f in (*.targets) do copy /Y "%f" "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild"" exited with code 255.
Done executing task "Exec" -- FAILED.

有什么建议吗?

【问题讨论】:

    标签: msbuild exec for-loop


    【解决方案1】:

    我刚刚在你之前的问题中解释过。在这种情况下,您需要在变量前面添加额外的 % 。 FOR命令的帮助说明如下

    批量使用 FOR 命令 程序,指定 %%variable 而不是 % 变量。

    【讨论】:

      【解决方案2】:

      必须使用 %% 而不是 %。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-24
        • 1970-01-01
        • 2012-02-14
        • 1970-01-01
        • 2011-11-27
        • 1970-01-01
        • 2011-09-22
        • 2018-07-23
        相关资源
        最近更新 更多