Search code examples
visual-studio-extensionsvisual-studio-2022

Launch an Extension command at Visual Studio 2022 launch?


I've written a VS 2022 Extension containing commands that I'd like to run at the launch of Visual Studio 2022.

The command run fine if executed from a menu item but I cannot determine where a call to the command should be placed if I wish it to be called immediately after VS 2022 starts.

The VS commandfile functions New() and InitializeAsync() do not appear to be called until the first command is launched by a menu item (because the extension isn't loaded until called upon).

Is there a method of making the extension ready/initialized so it can run a command at startup, or to run the command at startup and force it to initialize?


Solution

  • You can configure an AsyncPackage to auto-load with the instructions here. Note there is some asynchrony so if you need it to run precisely at certain point you may have issues; we limit the ability for that because when everybody writes their package to do something on startup, Visual Studio startup then takes forever.