Skip to content

Improve NuGet.targets perf #1866

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

Merged
merged 1 commit into from
Dec 14, 2017
Merged

Improve NuGet.targets perf #1866

merged 1 commit into from
Dec 14, 2017

Conversation

emgarten
Copy link
Member

@emgarten emgarten commented Dec 13, 2017

  • Add BuildInParallel to MSBuild tasks
  • Add SkipNonexistentTarget support
  • Reduce TargetFramework iteration

The dg file output from the restore target is identical to before the changes and that is covered by existing tests.

The only behavior change here is that invalid projects will now cause restore to fail since we can exclude projects without restore targets through SkipNonexistentTarget and no longer need to use ContinueOnError for probing projects. I've verified this manually, but adding automated tests for this requires MSBuild 15.5 on the test machines which isn't yet available.

Fixes NuGet/Home#6310
Fixes NuGet/Home#6311
Fixes NuGet/Home#6312
Fixes NuGet/Home#6061

//cc @rrelyea @jeffkl @AndyGerlicher @mikeharder

* Add BuildInParallel to MSBuild tasks
* Add SkipNonexistentTarget support
* Reduce TargetFramework iteration
@emgarten emgarten force-pushed the dev-emgarten-targetPerf2 branch from cbc76d6 to 5911b69 Compare December 13, 2017 20:07
@emgarten emgarten changed the title [WIP] Improve NuGet.targets perf Improve NuGet.targets perf Dec 13, 2017
Copy link

@jainaashish jainaashish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👏 Can we also log a tracking item to add tests once MSBuild is upgraded on vsts agents?

@emgarten
Copy link
Member Author

@jainaashish I've opened NuGet/Home#6315 for this

Copy link
Contributor

@jeffkl jeffkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving perf, hopefully we can find a way to make this on by default.

I'd also like to investigate if we'd get any perf gains by using IBuildEngine3.BuildProjectsInParallel

// When BuildInParallel is used with ContinueOnError it does not continue in
// some scenarios.
// Allow opt in to msbuild 15.5 behavior with NUGET_RESTORE_MSBUILD_USESKIPNONEXISTENT
var nonExistFlag = Environment.GetEnvironmentVariable("NUGET_RESTORE_MSBUILD_USESKIPNONEXISTENT");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not in love with the fact that this is entirely opt-in. If there's a smart way for us to detect they're using MSBuild 15, I think it should be on by default and be opt-out. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any ideas on how to get that? Since this is only for nuget.exe I was planning to fix that in a later PR. MSBuild and dotnet will use the 15.5 features by default.

Ideally it would determine this in the target, but the only property I could find was for 15.0 and it did not include the minor version.

NuGet could potentially probe the msbuild.exe it finds to read the assembly version, it might be worth the cost of this.

@emgarten emgarten merged commit c76d1c2 into dev Dec 14, 2017
@emgarten emgarten deleted the dev-emgarten-targetPerf2 branch December 14, 2017 19:47
%(_MSBuildProjectReferenceExistent.SetPlatform);
$(_GenerateRestoreGraphProjectEntryInputProperties)"
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)">
SkipNonexistentTargets="true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emgarten
Any reason fro not adding SkipNonexistentProjects="true" in this call?

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

Successfully merging this pull request may close these issues.

4 participants