Visual-studio – Changing the Default “Copy to Output Directory” Setting for Text Files

visual-studio-2008

Does anyone know if there is a way to change a file type's default "Copy to Output Directory" setting in Visual Studio 2008?

I often add text files to my projects. They could be anything from readme files, or some usage information, or test files actually used by the app at runtime.

But I've never ever added a text file where I did not want it copied to the output directory on build.

I always want them copied, but I often forget to change the setting (esp if I am adding a bunch, as in the case of the test files). I'd like to set the default for Visual Studio so that ALL .txt files are ALWAYS copied to the output folder.

Does anyone know if there is a way to permanently change the default setting for .txt files so they are always copied?

Best Answer

You can achieve what you want by adding a postbuild event to your project containing the command

xcopy /d /y $(ProjectDir)*.txt $(TargetDir)