用MSBuild执行任务 [英] MSBuild exec task with for
问题描述
我试图运行以下命令作为MSBuild脚本的一部分:
for / R。 (* .targets)中的%f复制/ Y%fC:\程序文件(x86)\ MSBuild\Microso
ft\VisualStudio\TeamBuild
这些命令在exec中以下列方式实现:
<$ p $ (* .targets)中的/ R。%f复制/ Y& quot;%f& quot;& quot;" Exec WorkingDirectory =$(SolutionRoot) ; $(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild&安培; QUOT; />
该命令可以在控制台中正常工作,但是当试图从MSBuild运行时,出现错误: / p>
任务Exec
命令:
for / R。 (* .targets)中的%f复制/ Y%fC:\程序文件(x86)\ MSBuild \ Microsoft \ VisualStudio \TeamBuild
fC:\ Program在这个时候是意外的。
C:\ Users \rd-build\AppData\Local\Temp\OH Test2\Continuous.BuildTargets\BuildType\TFSBuild.proj(98,5):error MSB3073:The命令for / R。%f in(* .targets)do copy / Y%fC:\ Program Files(x86)\ MSBuild\Microsoft\VisualStudio\TeamBuild用代码255退出
完成执行任务执行 - 失败。
有什么建议?
我刚刚在你之前的问题中解释过。在这种情况下,您需要在变量前添加额外的%。在FOR命令的帮助下解释如下:
$ b
要在批处理
程序中使用FOR命令,指定%%变量而不是
%变量。
I am trying to run the following commands as part of an MSBuild script:
for /R . %f in (*.targets) do copy /Y "%f" "C:\Program Files (x86)\MSBuild\Microso
ft\VisualStudio\TeamBuild"
The commands is implemented in an exec the following way:
<Exec WorkingDirectory="$(SolutionRoot)" Command="for /R . %f in (*.targets) do copy /Y "%f" "$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild"" />
The command works fine from console, but when trying to run it from MSBuild I get the error:
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.
Any suggestions?
I have just explained in your previous question. In that case you need to add extra % in front of your variables. It is explained in help of FOR command as follows
To use the FOR command in a batch program, specify %%variable instead of %variable.
这篇关于用MSBuild执行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!