简体   繁体   English

通过脚本将项目添加到visual studio c ++解决方案

[英]Adding projects to a visual studio c++ solution via a script

I usually work on multi-project solutions in visual studio. 我通常在visual studio中处理多项目解决方案。 Since the solutions themselves are not stored in the repository, I spend some time adding in the various projects via visual studio(from a list which is part of the 'parent' project). 由于解决方案本身并未存储在存储库中,因此我花了一些时间通过visual studio(从“父”项目的一部分列表)添加各种项目。 I am wondering if I can acommplish this via a script. 我想知道我是否可以通过脚本来解释这个问题。 ie: 1. create a solution. 即:1。创建解决方案。 2 add projects to that solution. 2向该解决方案添加项目。

I have a supplementary I need to add to the above question. 我有一个补充,我需要添加到上述问题。 I can use the File.AddProject from within the command window of visual studio(assuming you have a project open). 我可以在visual studio的命令窗口中使用File.AddProject(假设你打开了一个项目)。 I can also use File.OpenExistingProject from outside of visual studio using devenv /command .. Now the only missing piece is how do I add exisitng project to the project(solution) that is open, from outside of visual studio. 我还可以使用devenv / command从visual studio外部使用File.OpenExistingProject。现在唯一缺少的是如何将exisitng项目添加到可视工作室外部打开的项目(解决方案)中。

You should give a try to CMake . 你应该尝试一下CMake Here is a CMakeLists.txt example that creates a library and two binaries using that library. 这是一个CMakeLists.txt示例,它使用该库创建一个库和两个二进制文件。 After using CMake program, you end up with a solution and 3 projects inside. 使用CMake程序后,最终得到一个解决方案和3个项目。

project(MyProject)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
file(GLOB_RECURSE common_files common/*.h common/*.cpp)
add_library(commonLibrary ${common_files})

file(GLOB_RECURSE projectA_files projA/*.h projA/*.cpp)
add_executable(ProgramA ${projectA_files})
target_link_libraries(ProgramA commonLibrary)

file(GLOB_RECURSE projectB_files projB/*.h projB/*.cpp)
add_executable(ProgramB ${projectB_files})
target_link_libraries(ProgramB commonLibrary)

I have to admit , I did'nt try Cmake , mostly because I thought what I was looking for should be exposed in visual studio itself. 我不得不承认,我没有尝试过Cmake,主要是因为我认为我想要的东西应该在visual studio中暴露出来。 I have the elements of the solution. 我有解决方案的要素。 windows command prompt to add an alias for AddExistingProject followed by a command prompt run of devenv /commandline. Windows命令提示符为AddExistingProject添加别名,然后运行devenv / commandline命令提示符。 It should be possible to write a script that utilizes these elements. 应该可以编写一个利用这些元素的脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 c ++ visual studio 2008问题,在一个解决方案中有两个项目 - c++ visual studio 2008 issue with two projects in one solution visual studio c++ 解决方案中有两个独立项目的问题? - visual studio c++ problem with two independent projects in a solution? Visual Studio C ++将文件副本添加到解决方案 - Visual studio c++ adding copy of file to solution 从Visual Studio C ++解决方案调用Python脚本 - Calling Python Script from Visual Studio C++ Solution 从 Visual Studio 解决方案和项目(不是 cmake)中的非托管 (C++/C) 代码创建 Nuget 包 - Create Nuget package from unmanaged (C++/C) code in Visual Studio Solution and projects (not cmake) MS Visual Studio解决方案,结合了非托管C ++项目和C#项目 - MS Visual Studio solution combining unmanaged C++ project and C# projects Visual Studio C ++解决方案编译 - Visual Studio C++ Solution compilation TeamCity使用Visual Studio解决方案构建C ++ - TeamCity building C++ with Visual Studio Solution C ++中的Visual Studio解决方案配置值 - visual studio solution configuration value in C++ 添加C ++项目后,Intellisense和代码建议在Visual Studio 2013中不起作用 - Intellisense and code suggestion not working in Visual Studio 2013 after adding C++ projects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM