Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild error: The command exited with code 255

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

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

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

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

Anyone know, How to resolve this issue? The IDE is VS2013, C++ project

Does the for may just not work in a batch file for visual studio?

like image 982
Alen Lee Avatar asked Oct 17 '25 13:10

Alen Lee


1 Answers

There is a difference when running commands in a batch script. You need to double your % signs. Try this:

for /f "tokens=*" %%a in ('dir /b /s /a-d "$(ProjectDir)lib"') do @copy "%%a" "$(TargetDir)" /y
like image 184
uncletall Avatar answered Oct 19 '25 01:10

uncletall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!