I'm developing a Visual Studio Extension for code analysis, the extension require to emit dll for user selected project, I have selected Microsoft.CodeAnalysis library to emit build artifact for selected project.
I was unable to find a way to open the current solution without specifying the path to sln file (added the sample code), How to get current sln path? any alternative approach to generate build artifact for selected project?
Edit: My use case: User open the VS IDE -> Open a .cs file -> he select "Analyze" option which will be added from my extension -> then the extension should compile the project which contains user opened .cs file.
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.MSBuild;
using (var workspace = MSBuildWorkspace.Create())
{
//Open current solution
var solution = workspace.OpenSolutionAsync("C:\test\abc.sln").Result;
//Select the project user is working on and build it
//
}