views:

83

answers:

1

I want to create an hour counter to monitor my development time on a project. I want the time to increase whenever a certain project is active in Visual Studio 2008.

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

+1  A: 

You can get the loaded solution via the DTE.Solution property, and the active document via DTE.ActiveDocument. There isn't really an "active project" because you never really activate projects, you only open solutions (which can contain multiple projects) and files (which happen to be in projects).

I suspect for a time-tracking requirement, getting the current solution would probably suffice. However, if you need to specifically distinguish between projects in the solution, you can do this using DTE.ActiveDocument.ProjectItem.ContainingProject.

itowlson