自动将目录中的所有文件添加到库项目
Automatically add all files in directory to library project
我们正在寻求为 link 针对 Visual Studio 中的几个项目创建一个库。该库的源代码在 Visual Studio 之外维护。有没有办法自动抓取*.cpp文件的指定目录(或多个目录)并自动将它们添加到库中?目前我们必须根据需要添加或删除文件(右键单击项目,添加,现有)。
此回答来自(@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
来自这个 SO 问题:How do I add an existing directory tree to a project in Visual Studio? 应该给你你需要的一切。
<Content Include="Path\To\Folder\*.cpp" >
我知道答案,而且它必须张贴在某个地方...我花了一点时间才找到,所以希望 这个 答案能帮助其他人找到 其他回答。
在VS2015中,用记事本打开项目文件project1.vcxproj
第三行,(在<项目默认目标......>下)添加:
<ItemGroup>
<ClInclude Include="D:\MyCode\*.h" />
<ClCompile Include="D:\MyCode\*.cpp" />
</ItemGroup>
我们正在寻求为 link 针对 Visual Studio 中的几个项目创建一个库。该库的源代码在 Visual Studio 之外维护。有没有办法自动抓取*.cpp文件的指定目录(或多个目录)并自动将它们添加到库中?目前我们必须根据需要添加或删除文件(右键单击项目,添加,现有)。
此回答来自(@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
来自这个 SO 问题:How do I add an existing directory tree to a project in Visual Studio? 应该给你你需要的一切。
<Content Include="Path\To\Folder\*.cpp" >
我知道答案,而且它必须张贴在某个地方...我花了一点时间才找到,所以希望 这个 答案能帮助其他人找到 其他回答。
在VS2015中,用记事本打开项目文件project1.vcxproj
第三行,(在<项目默认目标......>下)添加:
<ItemGroup>
<ClInclude Include="D:\MyCode\*.h" />
<ClCompile Include="D:\MyCode\*.cpp" />
</ItemGroup>