How to create a folder in bin/Release for Visual Studio Project?
My project calls external exe file, and I would like to place that exe file in bin/Release/External. But every time I rebuild my project everything is removed, so I can't just manually copy the file there. How should I do it?
For files, residing outside of the project folder working with Post build events provides the capability to copy files to the build folder of a project. Select project properties. Select the Compile tab for VB.NET, Build Events for C#.. In the bottom right hand corner select the Build Events... button (VB.ET only).
To copy this file to the build folder of the project, open the dialog for build events and replace the echo command with the following command, The absolute path name of the primary output file for the build (defined with drive, path, base name, and file extension). Macros in the post-build event editor.
So if your project creates an application, it will not place any DLLs into your bin folder. And if your project builds a library, you'll get an error when you try to debug it because you cannot execute a DLL.
The simplest way of doing it is by adding the desired folder to your project and the exe file on the folder. Change the properties of the exe file to "Content" and "Copy always".
The folders inside the bin folder of your project are always deleted when you clean your solution (unless you change the project properties, but this won't solve your problem).
The simplest way of doing it is by adding the desired folder to your project and the exe file on the folder. Change the properties of the exe file to "Content" and "Copy always".
By doing that, everytime you rebuild your solution, the output will have the folder and exe file.
If the Exe file changes, you can add it as a link; ensuring you will have the latest version every time.
Or another way again..
Use Post build event where you write DOS commands.
For example in your case you can write:
mkdir $(TargetDir)\External
xcopy SOURCE_DIR_EXE $(TargetDir)\External\EXE_NAME
create a folder in the project, place the exe file in it, and set "Copy To Output Directory" property to "Copy if newer".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With