-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Eliminate build process hop by loading MSBuild.dll into CLI process #16577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminate build process hop by loading MSBuild.dll into CLI process #16577
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Would it be better to just expose the method from MSBuild? It's clearly useful and that would avoid reflection on this fast path. |
Yes, I'm looking into packaging MSBuild.dll. Put it into either the existing Microsoft.Build.Runtime or a separate package. Still, even with reflection this should be about two orders of magnitude faster than launching a new process. |
I'm a little confused, how is packaging work necessary? You clearly have the dll present. |
0a4aec1
to
29f8e6b
Compare
The dll is present at run-time but the package it's coming from is built in a "special way" and not conducive to simply referencing it. The assembly is under |
…re tests run dotnet.dll from
This is now ready for review. |
src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
Outdated
Show resolved
Hide resolved
src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
Outdated
Show resolved
Hide resolved
src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
Outdated
Show resolved
Hide resolved
src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
Outdated
Show resolved
Hide resolved
src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj
Outdated
Show resolved
Hide resolved
src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj
Outdated
Show resolved
Hide resolved
src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
Outdated
Show resolved
Hide resolved
@dsplaisted @dotnet/dotnet-cli |
FYI, generally when I approve a PR I'm OK with folks going ahead and merging it if they haven't made major changes unrelated to the PR feedback. |
Fixes #16362
This PR adds the possibility to load MSBuild.dll into the CLI process and directly call its entry point. This is in addition to the existing logic of launching a new dotnet process with MSBuild.dll as the startup assembly. The new behavior is enabled by default and can be disabled by setting a newly introduced
DOTNET_CLI_RUN_MSBUILD_OUTOFPROC
environment variable. The motivation for this change is performance as the extra process costs us 100 - 150 ms per MSBuild invocation, depending on platform and CPU specs.Overall the change is straightforward but a few aspects deserve to be mentioned here:
Microsoft.Build.Runtime
package which has non-standard layout and requires the assembly reference to be provided manually (seeMicrosoft.DotNet.Cli.Utils.csproj
).