Rediger

Del via


Working with solutions in Visual Studio extensions

Here's a collection of small code samples on different ways to work with solutions.

Solution events

Listen to any solution event.

VS.Events.SolutionEvents.OnAfterOpenProject += OnAfterOpenProject;

...

private void OnAfterOpenProject(Project obj)
{
    // Handle the event
}

Is a solution open?

Check if a solution is currently open or opening.


bool isOpen = await VS.Solutions.IsOpenAsync();
bool isOpening = await VS.Solutions.IsOpeningAsync();

Get all projects in solution

Get a list of all projects in the solution.

var projects = await VS.Solutions.GetAllProjectsAsync();