Skip to content
Discussion options

You must be logged in to vote

IVsSolution.CloseSolutionElement is the method that you need to use.

To close the entire solution, call CloseSolutionElement(grfCloseOpts, null, null).
To close a single project, call CloseSolutionElement(grfCloseOpts, phier, null).
To close a single document, call CloseSolutionElement(grfCloseOpts, null, docCookie).

Here's an example using the toolkit:

Project? activeProject = await VS.Solutions.GetActiveProjectAsync();

if (activeProject != null) {
    IVsSolution solution = await VS.Services.GetSolutionAsync();
    activeProject.GetItemInfo(out IVsHierarchy hierarchy, out _, out _);
    solution.CloseSolutionElement(0, hierarchy, 0);
}

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mgryning
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants