Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio post build event command line "for" syntax

Solution1 : { Project1 (windows form), Project2 (class library) }

Trying to copy all .dll(s) I get from after compiling Project1, from the default directory (same as the .exe) to a /lib sub-folder.

if not exist Lib mkdir Lib
for %i in (*.dll) move /Y "$(TargetDir)%i" "$(TargetDir)Lib\%i"

I have problem with the for %i in (*.dll) syntax. What is the correct way of doing it?

Note: This would give no errors (but would copy only 1 .dll, not all):

if not exist Lib mkdir Lib
move /Y "$(TargetDir)first.dll" "$(TargetDir)Lib\first.dll"
like image 750
dimitris93 Avatar asked Sep 28 '22 21:09

dimitris93


People also ask

What is post-build event command line?

Post-build event command lineSpecifies any commands to execute after the build ends.

How do I run a batch file in post-build event?

If you go to the Properties page for your project, you should select the Build Events tab. You can type in the call to your batch file in the Post-build event command line text box. If you want to refer to the batch file using the paths included in the project or solution, you can click on the Edit Post-Build...

How do I open a build event in Visual Studio?

Go to Solution Explorer and right-click on the project then select Properties then go to the Build Events tab.

What is build events in Visual Studio?

Specify custom build events in Visual Studio By specifying a custom build event, you can automatically run commands before a build starts or after it finishes. For example, you can run a . bat file before a build starts or copy new files to a folder after the build is complete.


1 Answers

You were almost there. You should use a double percentage %% and do:

for %%i in (*.dll) do move /Y "$(TargetDir)%%i" "$(TargetDir)Lib\%%i"
like image 171
Patrick Hofman Avatar answered Oct 05 '22 07:10

Patrick Hofman