Copy always to output directory does not work

I've got a simple console project where I'm reading two Excel-files. The Excel-files are included in the project ("add existing item") and I've marked them with "Copy to Output Directory". However, they are not copied to the debug-directory when debugging/running the code.

I feel like I've forgotten something trivial. What do I need to do more?


In the file properties in Visual Studio, set:

Build action: None

Copy to output directory: Copy always


Changes to non-source code files don't cause a rebuild to occur - they aren't considered when the compiler does it's out of date checking.

Try forcing a complete rebuild by deleting your output directory completely (sometimes doing this from within Visual Studio isn't complete).

It may be that the files haven't been copied across because a full build hasn't been run.


None of this worked for my WPF project. You need to mark it Content + Copy Always.

Refer to this page for details on the different Visual Studio file properties.


Did you mark them as content?


I had an issue when some png files was renamed-excluded-added again to project. It seemed that VS2015 had lost tracking what to do with these files: although in VS the "Copy to output directory: Copy always" was set at the problematic files, CopyToOutputDirectory key was not present in csproj file. I had to change csproj manually from

<Content Include="xxx.png"/>

to this:

<Content Include="xxx.png">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>