Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 317
tomfox66 Avatar asked Dec 05 '25 15:12

tomfox66


1 Answers

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.

like image 121
itowlson Avatar answered Dec 07 '25 05:12

itowlson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!