Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy bin files on to Physical file location on Post Build event in VS2010

I want to copy my dll generated in bin folder to a file location on Post Build Event in vs2010.

Can some one help me on that.

Thanks

like image 912
Praneeth Avatar asked Jan 12 '11 00:01

Praneeth


People also ask

Where is Copy to Output directory property?

Add the file to your project, then in the file properties select under "Copy to Output Directory" either "Copy Always" or "Copy if Newer".

What does Copy to Output Directory mean?

"Copy to Output Directory" is the property of the files within a Visual Studio project, which defines if the file will be copied to the project's built path as it is. Coping the file as it is allows us to use relative path to files within the project.

How do I create a post-build event in Visual Studio?

In the Post-build event command line box, specify the syntax of the build event. Add a call statement before all post-build commands that run . bat files. For example, call C:\MyFile.


2 Answers

You want to add something like:

xcopy /Q /Y "$(TargetPath)" "C:\path\to\somewhere\" 

to you post-build event on the Build Events tab in the project properties page. The /Y will stop it from prompting you to confirm an overwrite.

If you also need to copy the .pdb file, you will need something like this:

xcopy /Q /Y "$(TargetDir)$(TargetName).*" "C:\path\to\somewhere\" 

You can see more substitution tokens (the $XXX values) by clicking the Edit Post-build... button in the properties tab and then expanding the Macros>> button.

like image 193
adrianbanks Avatar answered Oct 07 '22 00:10

adrianbanks


Right-click the project, then go to Properties->Build Events->Post-build command line.

Then type this in:

Cmd /C Copy "$(TargetPath)" "<YourTargetDirHere>" 

Does that help?

like image 22
user541686 Avatar answered Oct 06 '22 23:10

user541686