views:

1659

answers:

3

I am trying to run the following commands as part of a 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 &quot;%f&quot; &quot;$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild&quot;" />

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?

A: 

Had to use %% and not %.

Oddleif
+2  A: 

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.

kokeksibir
Thanks. I should have read the manual better :)
Oddleif
A: 

working like charm

Dilli