views:

57

answers:

0

Hello. I've created a .NET Add-in that is supposed to do something when a project is being built.

I know there are several ways to build a .NET project
a) Hitting F5 button
b) From Build menu
c) From Debug menu ( by debug-ing )
d) By building the solution ( builds the project checked for 'Build' in solution properties )
e) By right-click on a project -> Debug ..

I catch the 'OnBuildBegin' event :


m_BuildEvents = _applicationObject.Events.BuildEvents;
m_BuildEvents.OnBuildBegin += m_BuildEvents_OnBuildBegin;

void m_BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action)
{
...
}

When project gets built F5 button its easy to get the project object by checking the StartUpProjects.
When project gets built by using its right-click menu i just use _applicationObject.ToolWindows.SolutionExplorer selected items and check for projects.
I've encountered the following problems:
1. When building the solution, how can I tell which project is currently being built?
2. How can I tell if i'm building the project by using its right-click menu or by using the build menu ( or by hitting F5 etc. ) , in order to know how to switch between my two methods of finding the project object ?

Is there a way to tell, in any of the BuildEvents, which project is being build ?

Any help is appreciated. Thank you