Can I access the MsBuildWorkspace from within a MsBuild Task class?

后端 未结 1 1578
情书的邮戳
情书的邮戳 2021-01-22 19:21

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

1条回答
  •  礼貌的吻别
    2021-01-22 19:51

    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.

    0 讨论(0)
提交回复
热议问题