Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Use msbuild /restore instead of a separate process #7896

Merged
merged 3 commits into from
Oct 27, 2017

Conversation

nguerrera
Copy link
Contributor

@nguerrera nguerrera commented Oct 24, 2017

Use msbuild /restore instead of separate invocations where possible

Fix #7696

This saves 300ms on my machine for incremental build of a simple console app (from 1.4s to 1.1s).

We still have to miss out on this optimization when there is -f|--framework argument because we cannot force a TargetFramework global property on to the restore evaluation. Doing so completely breaks restore by applying the TargetFramework to all projects transitively. The correct behavior is to restore for all frameworks, then build/publish/etc for the given target framework. Achieving that still requires two distinct msbuild process invocations.

This also changes the verbosity of implicit restore from quiet to that of the subsequent command (default=minimal). Similar to global properties, we cannot specify a distinct console verbosity for the /restore portion of the overall execution. For consistency, we apply the same verbosity change to the case where we still use two separate msbuild invocations.

Output Before:

[Logo]
  qwert -> D:\temp\qwert\bin\Debug\netcoreapp2.0\qwert.dll.
[Summary]

Output After:

[Logo]
  Restoring packages for D:\temp\qwert\qwert.csproj...
  Installing Newtonsoft.Json 10.0.3.
  Restore completed in 763.37 ms for D:\temp\qwert\qwert.csproj.
  qwert -> D:\temp\qwert\bin\Debug\netcoreapp2.0\qwert.dll
[Summary]

In the incremental no-op restore case, only the line about "Restore completed in X for Y" is added.

NuGet/Home#4695 tracks reducing restores output when verbosity is minimal.

This also fixes an issue where the separate restore invocation's msbuild log would be overwritten by the subsequent command execution. However, this remains unfixed in the case where we still use two separate msbuild invocations.

The first two commits are strictly separate, but were getting in the way of test changes I needed to make so I tackled them here.

  • Remove necessary handling of verbosity in RestoreCommand
  • Fix #7009, Cannot pass /clp:NoSummary to dotnet build

We were taking care to set the console verbosity to minimal, but
only when no verbosity argument is passed. However, the default
verbosity for all CLI msbuild commands is already minimal and so
we can just get out of the way.
@nguerrera nguerrera force-pushed the one-process-restore branch 5 times, most recently from 2a964a4 to 9f8a03f Compare October 26, 2017 20:44
It is not currently possible when there is a -f|--framework argument because
we cannot force a TargetFramework global property on to the restore evaluation.
Doing so completely breaks restore by applying the TargetFramework to all
projects transitively. The correct behavior is to restore for all frameworks,
then build/publish/etc for the given target framework. Achieving that still
requires two distinct msbuild invocations.

This also changes the verbosity of implicit restore from quiet to that
of the subsequent command (default=minimal). Similar to global properties,
we cannot specify a distinct console verbosity for the /restore portion of
the overall execution. For consistency, we apply the same verbosity change
to the case where we still use two separate msbuild invocations.

This also fixes an issue where the separate restore invocation's msbuild log
would be overwritten by the subsequent command execution. However, this remains
unfixed in the case where we still use two separate msbuild invocations.
@nguerrera
Copy link
Contributor Author

nguerrera commented Oct 26, 2017

cc @davkean @AndyGerlicher

@livarcocc Can you take another look? I changed it quite a bit since your review.

@nguerrera nguerrera requested a review from a team October 26, 2017 23:53
@nguerrera nguerrera changed the title WIP One process restore Use msbuild /restore instead of a separate process Oct 27, 2017
@@ -37,6 +37,8 @@ public static BuildCommand FromArgs(string[] args, string msbuildPath = null)

var appliedBuildOptions = result["dotnet"]["build"];

msbuildArgs.Add($"/clp:Summary");

This comment was marked as spam.

This comment was marked as spam.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants