Search code examples
devenv

how to save VS solution changed by devenv /Command "File.AddExistingProject"


I am trying to create batch script to automate the build. In which I need to add existing project in a solution, for which I used below::

devenv solutionPath /Command "File.AddExistingProject" projectPath

This command adds the existing project and opens the solution. But problem starts here, now how to save this solution(with added existing project). I have found (devenv solutionPath /Command "File.SaveAll") option but it opens the solution in another VS instance and saves it.

Please help to save the modified solution using devenv.


Solution

  • I have got the solution. I have made below vbs script .

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.AppActivate "Microsoft Visual Studio" 
    WshShell.SendKeys "{ENTER}" 
    WshShell.SendKeys "^+s" 
    

    And after using AddExistingProject command I have called this vbs script. It has worked for me.