So you’re creating a VSIX package that does not have a menu items, tool windows or command? But still you want the package to get loaded (i.e. executed) by the IDE? What a crazy thing to wish for, one might think after spending hours searching the internet on how to do that. But don’t abandon hope, yet, since the answer is nigh.
If you want to, you can check out the original article at MSDN, but the short answer is use the ProvideAutoLoadAttribute to annotate you package. In addition, use the VSConstants class along with its nested class UICONTEXT to define the visual studio context where the package will automatically be loaded.
Example:
[PackageRegistration(UseManagedResourcesOnly = true, RegisterUsing = RegistrationMethod.Assembly)] [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] [Guid(GuidList.guidDebuggerAutoAttachPkgString)] [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string)] public sealed class MyTopnotchPackage : Package { // maybe you'd want some code inside here... }
Perfect. I have a package with a menu item with dynamic visibility and default of invisible. Without this attribute (ProvideAutoLoad) the package never loads. Thanks!