Dwza Dwza - 3 months ago 14
C# Question

Copie folders on release if included in VS-Project

I created a c# Project in visual studio 2015. Now I have a folder in my project e.g.

foobar


When I call release, the folder is copied to
bin\release
. Now I have a second folder. e.g.

halloworld


Hitting the release will only copy
foobar
.

Atm I have 5 folders and two of them gets copied...

How can I tell VS to copy that folder or not ?

Answer

To my knowledge it depends on the content of the folders. If the folder contains nothing or just artefacts that get compiled VS thinks that there is no reason in copying them.

If you artefacts within your folders that should be copied to the output directory those folders will be copied.

Have a look at the properties of the folder content:

Here readme.txt will go to ABC/readme.txt enter image description here

The class SomeClass will just get compiled... enter image description here

If you want to create empty folders in your output directory, I would consider adding a custom task to your msbuild-project:

See MSDN documentation for mkdir task

Edit by Dwza: (For all who may search the same)

Total folders can be copied into bin\release or bin\debug by setting custom copy commands in

Project > Properties > Build Events> Post Build

Sample

xcopy "$(ProjectDir)yourFolder" "$(TargetDir)newFoldername" /Y /R /I /E

For files you may use copy instead of xcopy since xcopy would check if its a folder or file...

copy "$(ProjectDir)folder\file.ext" "$(TargetDir)newFilename.ext"

If you more familiar with xcopy than you may have to use a hack to copy files

xcopy "$(ProjectDir)folder\file.ext" "$(TargetDir)newFilename.ext*"

The * in the end of the line will force xcopy to tread it as File.