As far as I understand, Roslyn have introduced the concept of Workspaces. One implementation of Workspaces is the MsBuildWorkspace.
My question is, can I from within a
I suspect that this is the purpose of MsBuildWorkspace
No.
The point of MsBuildWorkspace
is to parse an MSBuild project or solution into a Roslyn workspace.
MSBuild itself (which is what actually runs your MSBuild task) does not use Roslyn at all (it just invokes the C# compilation task, which is implemented using Roslyn), so there is no existing MsBuildWorkspace
that you could fetch.
You could create your own MsBuildWorkspace
from the project file.