I have a macro that opens a solution, connects to SourceSafe and downloads the latest version of each file inside the solution. To this point all works correctly.
Now I want to execute devenv.exe with /command option to run this macro and close the Visual Studio environment once the source code is downloaded, and at this point I’m having some problems:
If I use a macro like the one following these lines, Visual Studio starts, loads the solution, starts getting source code and then exits without waiting for the code to be completely downloaded.
DTE.Solution.Open("C:\ApeironDev\Soluciones\SolucioApeiron\SolucioApeiron.sln")
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("SolucioApeiron").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.ContextGetLatestVersion")
DTE.ExecuteCommand("File.Exit")
If I add a line to Sleep the macro for some time, say 20 minutes, this crashes with an error regarding error in COM call (I know, this is not an elegant way to do the job, but in order to test…).
DTE.Solution.Open("C:\ApeironDev\Soluciones\SolucioApeiron\SolucioApeiron.sln")
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("SolucioApeiron").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.ContextGetLatestVersion")
Threading.Thread.Sleep(New System.TimeSpan(0, 20, 0))
DTE.ExecuteCommand("File.Exit")
What I’m searching for is a way to start Visual Studio, load a solution, get the latest version of the source code (waiting for the process to finish) and then close the Visual Studio environment. Any help?
Clarification, To run the macro I use the following command line:
devenv.exe /command "Macros.MyMacros.SourceControl.GetLastVersion"
Where Macros.MyMacros.SourceControl.GetLastVersion is the complete path to the macro containing the code above described.