You can just use Visual Studio's own events for that. Get an instance of the DTE
object and subscribe to the OnBuildBegin
and OnBuildDone
events.
You can see this in action in the Clippy ReSharper extension. It subscribes to the events, and gets the DTE
instance from the call to Shell.Instance.GetComponent<DTE>()
.
Note that how you reference the DTE
type is very important - it's a COM reference, and shouldn't be referenced as a Embedded PIA intro type, or ReSharper's component model container will see it as a different type to the DTE
instance it knows about. Instead, simply reference it as a non-PIA type:
<Reference Include="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>..\..\lib\envdte.dll</HintPath>
</Reference>