views:

31

answers:

2

I usually work on multi-project solutions in 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). I am wondering if I can acommplish this via a script. ie: 1. create a solution. 2 add projects to that solution.

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). 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.

+1  A: 

You should give a try to CMake. Here is a CMakeLists.txt example that creates a library and two binaries using that library. After using CMake program, you end up with a solution and 3 projects inside.

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)
tibur
Thanks , I'll take a look.
Pradyot
Another possibility is using the windows commandline with the devenv /Commandline .. though admittedly i don't know exactly how to achieve this.
Pradyot
A: 

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. 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. It should be possible to write a script that utilizes these elements.

Pradyot