all this starts with a question sent to me by one of our security guys. He asks me whether this behavior below is normal and expected. And quite frankly : I don't know !
So, I search a bit but could not find the right answer to this question. Is it normal and expected that VS 2022 mostly uses msbuild.exe but sometimes switches to vbcscompiler.exe to build what seems to be the same project ? Or is it related to UT/IT VS tooling (we have an Integration Test project on this very project) ?
Thanks in advance for your knowledge.
MSbuild.exe runs the build (projects, solutions) which includes copying files, resolving references, installing NuGet packages, etc. One part of the build process is to (eventually) compile some source files. For C# that would be the C# compiler (or "Roslyn"), obviously.
The compiler can be invoked directly using csc.exe
or the Csc MSBuild Task
.
To speed up compilation Roslyn uses a client/server-like model. VBCSCompiler.exe
is the server part. It caches certain things for repeated builds to make the overall build faster.
So for expository purposes, what you see is the following logical structure:
With the noteworthy fact that VBCSCompiler.exe
is a server process and doesn't go away after each CSC invocation (which would defeat its purpose - see above). For the same reasons, BTW, MSBuild.exe processes are also reused and typically (compare with the /nodeReuse:false
command line option) don't go away after your build is complete.
This is all a very simplistic presentation of the actual model, you might want to dig deeper if you're interested. Especially, the interaction between Visual Studio, MSBuild, and the compiler is in practice a little more complicated.