MSBuild error: command exited with code 255

I want to do something before build, so I add command line to Pre-Build Event.

for /f "tokens=*" %a in ('dir /b /s /a-d "$(ProjectDir)lib"') do @copy "%a" "$(TargetDir)" /y

      

This command to copy all files in the lib directory (project directory) to debug the target.

But when I create a project, it has error MSB3073: command "for / f" tokens = * "% a in ('dir / b / s / ad" $ (ProjectDir) lib "') do @copy"% a "" $ (TargetDir) "/ y: VCEnd" exits with code 255. But I execute the command in CMD, no problem.

Does anyone know how to fix this problem? IDE - VS2013 project, C ++

Could this setting just not work in a batch file for visual studio?

+3


source to share


1 answer


There is a difference when running commands in a script package. You need to double the signs %

. Try the following:



for /f "tokens=*" %%a in ('dir /b /s /a-d "$(ProjectDir)lib"') do @copy "%%a" "$(TargetDir)" /y

      

+5


source







All Articles