Automatically run extension code in Visual Studio at startup

Can I create an extension for Visual Studio that runs in the background as soon as the user opens the Visual Studio development environment? For example, I create an extension that receives the current active file address in Visual Studio (with C #), but I would like this extension to always start in the background without the need for a user to activate it by pressing a button or pressing a key.

Is this possible, and if so, what is the best way to do this?

Any help would be greatly appreciated! Regards, Erfan

+6
source share
3 answers

Since you tagged your question with visual-studio-2010 , I assume that you are working on an add-in and not with "VSPackage Extensions".

In this case, you can use the OnConnection event OnConnection .

If you work with VSPackage extensions, you can use the ProvideAutoLoad attribute.

Just find them, you will find enough information. Both methods are also described below in the section "How to run my add-in code in VSPackage?"

+4
source

For VS 2010 and above, the recommended extension approach is the package (VS 2015 does not allow add-ons).

To download a package when Visual Studio starts, see HOWTO: Auto-load a Visual Studio package .

After downloading, your package may be interested in two different choices:

+3
source

For the extension, add the following attribute to the Package class, this will load the extension when the solution is not open in visual studio. I tested this with VS 2015 and 2017.

 [ProvideAutoLoad(UIContextGuids80.NoSolution)] 
+1
source

Source: https://habr.com/ru/post/983387/


All Articles