We're looking to create a library to link several projects against in Visual Studio. The source for this library is maintained outside of Visual Studio. Is there a way to automatically scrape a specified directory (or directories) for *.cpp files and automatically add them to the library? Currently we have to add or delete files as required (right click project, add, existing).
Asked
Active
Viewed 955 times
2 Answers
2
This answer from (@Yuchen Zhong)
In visual studio 2015, this is how you do it.
If you wanted to automatically include all descendant files below a specific folder:
<Content Include="Path\To\Folder\**" />
Reference: http://jamesrpatterson.com/blog/automatic-include-in-project-for-visual-studio
from this SO question: How do I add an existing directory tree to a project in Visual Studio? should give you all you need.
<Content Include="Path\To\Folder\*.cpp" >
I knew the answer, and that it must be posted somewhere...took me a little bit to find, so hoping this answer helps others find the other answer.
1
In VS2015, open in notepad the project file project1.vcxproj
In third line, (Under < Project Default Target....... >) Add:
<ItemGroup>
<ClInclude Include="D:\MyCode\*.h" />
<ClCompile Include="D:\MyCode\*.cpp" />
</ItemGroup>

Mendi Barel
- 3,350
- 1
- 23
- 24