Is it possible to modify a solution, and use envdte tools, from a command-line project ?
I have an add-in that modifies a solution. But... the changes are required for over a hundred projects... So I'd like to make a c# program that has the same logic, only it iterates through all solution files.
The add-in starts with
EnvDTE.Solution solution = (EnvDTE.Solution)application.Solution;
where DTE2 application
is passed from the add-in...
How can I get the same solution, which then I query for projects... From a separate program, that will only know the solutionPath ?
Is it possible to open the solution, process it, and close it - to move on to the next solution ?
Microsoft gives this example http://msdn.microsoft.com/en-us/library/envdte._solution.open(v=vs.100).aspx
But I don't know what dte is in the context...
Thank you...
VS 2010
edit: I did what the answer below suggests. Slightly modified, using the link: http://msdn.microsoft.com/en-us/library/ms228772(v=vs.100).aspx
Thank you
Yes you can. You just need to activate an instance using the COM CLSID for Visual Studio. An example is below. It actually creates a solution and adds two projects to it but the same initialization applies when opening an existing solution.
A couple of caveats:
Mind the COM threading model. The code created from the console app template is sufficient:
If you have a powerful VS extension like ReSharper installed, you might be better off suspending it if you don't need it for the VS automation. ReSharper had VS commands that control it.