Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy to Output Directory in Visual Studio 2017

Hello I am walking through this tutorial here.

I have created a Console App project in Visual Studio 2017 and have successfully added references to the EmguCV library. However I am struggling with the OpenCv files.

After adding them to the solution, then highlighting them and clicking properties, there is no available option to "Copy to Output Directory".

enter image description here

The properties window only displays the Misc section. How do enable "Copy to Output Directory" for these files in VS 2017?

like image 852
RyeGuy Avatar asked May 10 '17 00:05

RyeGuy


People also ask

How do I copy output in Visual Studio?

Copy to Output Directory is a property for files within a Visual Studio project. Select a Windows Form in a project, find Copy to Output Directory and note Copy to Output Directory is set to [Do not copy].

How do I change the output directory in Visual Studio?

To place all solution outputs in a common directory Click on one project in the solution. On the Project menu, click Properties. In each project, depending on its type, select either Compile or Build, and set the Output path or Base output path to a folder to use for all projects in the solution.

How do I copy a folder in Visual Studio?

Use the CopyDirectory method to copy a directory to another directory. This method copies the contents of the directory as well as the directory itself. If the target directory does not exist, it will be created.

What is copy to output directory in Visual Studio?

Copy to Output Directory is a property for files within a Visual Studio project. Select a Windows Form in a project, find Copy to Output Directory and note Copy to Output Directory is set to [Do not copy].

How do I change the build output directory in Visual Studio?

Change the build output directory To open the project's property pages, right-click on the project node in Solution Explorer and select Properties. Select the appropriate tab based on your project type: For C#, select the Build tab.

Why is copy to output directory not working on my project?

When files are not located in a project folder Copy to Output Directory does not work as Copy to Output Directory only works on project files. 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.

How does copy to output directory handle required file requirements?

In addition, when a required file must be included e.g. Excel, text file etc. Copy to Output Directory handles this requirement by setting it to [Copy always], [Copy if Newer] or [Do not copy]. Adding a database to a project from Visual Studio’s Solution Explorer Copy to Output Directory will be set to [Copy always].


1 Answers

The Solution Items are part of the solution folder structure and do no belong to a project, Copy to Output directory relates to a project build, which copies the items to the output directory on a successful build.

In your case, you want to copy those 2 dlls when you build your ConsoleOCR Project, you can use post build events.

Go to your project, right click and select Properties. Then go to Build Events tab, click Edit Post-Build and specify the commands:

xcopy "$(SolutionDir)\opencv_core2410.dll" "$(TargetDir)"
xcopy "$(SolutionDir)\opencv_imgproc2410.dll" "$(TargetDir)"

I assume you use those DLLs as references in your project, you can go to your References in the project and right click them then change the property of Copy Local to True.

like image 123
Yaman Avatar answered Sep 28 '22 10:09

Yaman