How can I programmatically get a loaded project in Visual Studio 2008?

I want to create an hour meter to track project development time. I want time to increase whenever a project is active in Visual Studio 2008.

Can I progammatically find out which * .csproj file is currently active in VS2008?

+3
source share
1 answer

You can load the downloaded solution using the property DTE.Solutionand the active document via DTE.ActiveDocument. Actually, there is no "active project" because you never activate projects, you only open solutions (which may contain several projects) and files (which are in projects).

I suspect time tracking requires a current solution, probably enough. However, if you need to specifically distinguish between projects in a solution, you can do this using DTE.ActiveDocument.ProjectItem.ContainingProject.

+1
source

Source: https://habr.com/ru/post/1726398/


All Articles