Reputation: 4677
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.
Upvotes: 2
Views: 3895
Reputation: 343
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.
Upvotes: 5
Reputation: 129
In a VS2019 c++ console project it was just a litlle different:
<ItemGroup>
<None Include="Run.bat">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Upvotes: 0
Reputation: 4677
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>
Upvotes: 7