Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Acessing currently opened solution in a vsix project

I want to access the path to currently open solution in Visual Studio from a vsix project. How can I get that?

This thread tells if a solution is open or not but gives nothing about the path of the opened solution

like image 713
Harjatin Avatar asked Jul 08 '15 12:07

Harjatin


People also ask

How do I open an existing solution in Visual Studio?

You can open any solution, project, folder or file in Visual Studio Code by simply right-clicking it in Solution Explorer and select Open in Visual Studio Code.

Where can I find VSIX files?

Installation location During installation, Extensions and Updates looks for the contents of the VSIX package in a folder under %LocalAppData%\Microsoft\VisualStudio\14.0\Extensions. By default, the installation applies only to the current user, because %LocalAppData% is a user-specific directory.

How do I open the last project in Visual Studio?

Expand Environment, and then choose Startup. In the On startup, open list, choose what you want to happen after Visual Studio launches. You can choose from Start window (which lets you open a new or existing project), Most recent solution, or Empty environment.

How do I unload a project in Visual Studio 2022?

Click the UModel project in Solution Explorer of Visual Studio. 2. On the Project menu, click Unload project.


2 Answers

I would suggest to avoid EnvDTE as much as possible when developing packages and use native services whenever possible. In this case IVsSolution.GetSolutionInfo

like image 99
Carlos Quintero Avatar answered Sep 29 '22 22:09

Carlos Quintero


I use this:

    public string GetInitialFolder(DTE dte)
    {
        if (!dte.Solution.IsOpen)
            return null;
        return System.IO.Path.GetDirectoryName(dte.Solution.FullName);
    }

But expect it to error, sometimes it cannot return a path!

like image 21
ErikEJ Avatar answered Sep 29 '22 22:09

ErikEJ