user3111311
user3111311

Reputation: 8001

How to create a folder in bin/Release for Visual Studio Project?

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?

Upvotes: 6

Views: 20323

Answers (8)

Nahuel Ianni
Nahuel Ianni

Reputation: 3185

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.

Upvotes: 11

Reza
Reza

Reputation: 19843

Create a folder with your desire name in your solution, add your files there (Add Existing Item), right click on files and set BuildAction to None and CopyToOutputDIrectory to Copy Always or Copy If Newer, rebuild your project, that is it!

Upvotes: 0

Dmitry
Dmitry

Reputation: 14059

Try to integrate this into the build process:

<ItemGroup>
    <_CopyItems Include="$(your_path)\*.*" />
</ItemGroup>
<Copy
    SourceFiles="@(_CopyItems)"
    DestinationFolder="$(BuildOutput)\External"
/>

Upvotes: 0

Tigran
Tigran

Reputation: 62246

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

Upvotes: 6

gsharp
gsharp

Reputation: 27927

You could Use a Post-build event for that. Project Properties -> Build Events -> Post build event commandline "copy from a to b"

or second option, you create a folder "External" in your project and put your exe there. set the property "Copy to Output Direcotry" to "Copy always".

Upvotes: 0

Rytis I
Rytis I

Reputation: 1303

Add mkdir command Post-build event command line in project options -> Build Events

Upvotes: 0

Felice Pollano
Felice Pollano

Reputation: 33252

create a folder in the project, place the exe file in it, and set "Copy To Output Directory" property to "Copy if newer".

Upvotes: 2

James
James

Reputation: 82096

Just create a folder in your project, add a reference to your exe in that folder and then set the Copy to Output Directory property of the exe to Copy always / Copy if newer.

The folder structure of where the exe is will be replicated in the output directory.

Upvotes: 2

Related Questions