I have a number of *.txt files included in my Visual Studio 2017 C++ project (*.vcxproj). Does anyone know how to get Visual Studio to copy these files to the output directory?
I found a similar question for VS 2010, but that answer doesn't work in Visual Studio 2017.
In the *.vcxproj file, change:
<Text Include="Filename.txt" />
to:
<Content Include="Filename.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Then in the *.vcxproj.filters file, change:
<Text Include="Filename.txt">
<Filter>Resource Files</Filter>
</Text>
to:
<Content Include="Filename.txt">
<Filter>Resource Files</Filter>
</Content>
Update for 2019 users:
An easy way to do this is from the file's Property Pages (right-click on the file in Solution Explorer, then click Properties).
Under Configuration Properties > General, change Item Type to "Copy file." By default, this will create a copy of the file in the build destination directory. Once you hit Apply, a new property page called Copy File will appear on the left where you can customize this behavior.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With