I have a VS2008 I want to copy certain files from a directory into my /bin/
folder. I have set the files (located in /common/browserhawk/
) to "Copy to Output Directory". However, it copies the folder structure as well: the files are copied to /bin/common/browserhawk/
How do I get these files to copy to just /bin/
? I do not want to store these in the root of the website to get them to copy correctly.
Related Question: Visual Studio adds .dll and .pdb to project after compiling
You can add a Post Build Event to copy the files.
Go to project properties, Build Events tab and add the following to the Post-build event command line:
Be sure to include the quotes if your project path has spaces in it.
Add the following to your .csproj/.vbproj file
Then change the Build Action of any files you want in the root folder to RootContent.
You could build a batch file to copy the files and execute it as a post-build event.
I believe the XCOPY command handles directories and files better. Therefore,
Which allows for creating folders off the target directory.
The Project folder/file structure of:
Becomes:
If you edit the .csproj / .vbproj in a text editor, you can control where the file is placed in the output directory, and also what name the file will have in the output directory. For example:
This will put the file
content\someContent.txt
intobin\someContentInOutputDirectory.txt
. You can also choose a subdirectory inbin
if you want; simply add it to the Link element.I have used this in VS2010 and VS2015. I prefer this solution because:
Toward the beginning of project file:
Borrowed From This Answer
After the Microsoft .targets Import:
Borrowed From This Answer