Visual Studio Post-build event: for %f in (set) command
Asked Answered
W

1

14

This command in the Visual Studio 2010 Post-build event

for %f in ("$(ProjectDir)$(OutDir)*.dll") do echo %f

(echo will be replaced with some other tool) gives me the error

The command "[...]" exited with code 255.

I guess I have to escape the outermost round brackets but I don't know how. I tried \( and ((.

Wash answered 13/5, 2011 at 12:18 Comment(1)
why go into dos? why not use msbuild for your post-build event?Bohr
M
20

You might need to use %%f instead of %f for the first one (and maybe the second one). In a batch file (which VS might use to implement these custom build steps), you have to use the extra % for identifiers.

Edit: here's the first part of the output from help for on the command line.

Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

%variable Specifies a single letter replaceable parameter. (set) Specifies a set of one or more files. Wildcards may be used. command Specifies the command to carry out for each file. command-parameters Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different from %I.

Mason answered 13/5, 2011 at 13:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.