简体   繁体   中英

How is Roslyn related to MsBuild?

I'm wondering: How exactly is Roslyn related to MsBuild?

My understanding was that

  1. Roslyn is a compilation engine
  2. MsBuild is is mostly a set of specifications of how a project is set up - ie basically a definition schema for .csproj, .sln files and so on.

Then again, MsBuild also ships with an msbuild.exe - which, correct me if I'm wrong, is able to actually compile projects. But how would this tie in with Roslyn, assuming msbuild.exe can compile projects, but so can Roslyn?

Does msbuild.exe use Roslyn to compile, in case of MSBuild 15? Are they completely seperate? Am I misunderstanding anything?

And furthermore & more specifally: Assuming I want programatically create simple .csproj files, and use Roslyn's MSBuildWorkspace to handle/populate and finally compile these. Would the end user of my application need to have Microsoft's build tools installed on their machine? Or is this not necessary, as Roslyn would be able to read & compile these independently of any local MSBuild installation?

MSbuild is the build system for Visual Studio. It calls the C# compiler to compile C# projects. Roslyn is the C# compiler (and the VB compiler). So msbuild uses Roslyn.

However, Roslyn also includes more things than just the compiler. It also includes a VS plug in that gives you IDE features (completion lists, colorization, code fixes, etc).

In addition, Roslyn is also an API for analyzing source code, that you can use from your own app. For this last scenario is has an API known as MSBuildWorkspace that you can use to open a project or solution for analysis. This workspace uses MSBuild to figure out all the pieces of the projects and solution. So this part of Roslyn uses MSBuild.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM