-
Notifications
You must be signed in to change notification settings - Fork 702
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
Add a restore task report on whether the build files changed #1831
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great way to solve this 🚀
foreach (var summary in restoreSummaries) | ||
{ | ||
// Success does not matter here, as long as the files are not changed | ||
if(summary.BuildFilesChanged) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing
@@ -68,6 +69,9 @@ public class RestoreTask : Microsoft.Build.Utilities.Task, ICancelableTask, IDis | |||
/// </summary> | |||
public bool HideWarningsAndErrors { get; set; } | |||
|
|||
[Output] | |||
public string OutputRestoreChangedImportsProjectList { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a summary for this
// Success does not matter here, as long as the files are not changed | ||
if(summary.BuildFilesChanged) | ||
{ | ||
projectsWithImportsChanged.Append(summary.InputPath).Append(';'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be easier to just do:
string.Join(";", restoreSummaries.Where(e => e.BuildFilesChanged).Select(e => e.InputPath))
instead of the string builder and loops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is....didn't think too much about it, my instinct was to not add the extra linq overhead lol :)
This is called only once though :D
So I can change to make it more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get avoiding Linq, it's always a trade off it seems. I'm fine with either one.
@@ -65,6 +65,12 @@ public class RestoreResult : IRestoreResult | |||
/// </summary> | |||
protected string CacheFilePath { get; } | |||
|
|||
/// <summary> | |||
/// Indicates whether the build files have changed. It will only be updated after the restore result has been committed. It will false Commit has not be called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be false if Commit
@@ -89,7 +89,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
Main entry point for restoring packages | |||
============================================================ | |||
--> | |||
<Target Name="Restore" DependsOnTargets="_GenerateRestoreGraph"> | |||
<Target Name="Restore" DependsOnTargets="_GenerateRestoreGraph" Returns="$(RestoreChangedImportsProjectList)"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment to the targets about this, it is covered in the task but users don't always see that source.
572e659
to
352f51e
Compare
@@ -87,9 +87,11 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
============================================================ | |||
Restore | |||
Main entry point for restoring packages | |||
Returns a property with comma delimited projects whose imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it comma delimited or semicolon delimited list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semicolon...nice catch :)
// Success does not matter here, as long as the files are not changed | ||
if(summary.BuildFilesChanged) | ||
{ | ||
projectsWithImportsChanged.Append(summary.InputPath).Append(';'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it shouldn't add an additional ;
at the end of the list. It will unnecessary increase load for msbuild to always ignore last item when they split on semicolon.
foreach (var summary in restoreSummaries) | ||
{ | ||
// Success does not matter here, as long as the files are not changed | ||
if(summary.BuildFilesChanged) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will there be a case where restore failed but still changed the targets/props file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jainaashish
Yeah, restoreSuccess is part of the props.
@jainaashish Addressed your feedback. |
🔔 |
@mishra14 |
Hey folks, I'm back from vacation but I've been gone for the lifetime of this. Can someone bring me up to speed? |
@rainersigwald the idea here is that restore will tell MSBuild whether or not it changed props/targets files. If it didn't make any changes then MSBuild can avoid clearing the cache. Since then we found that this may not change much. Restore needs to run with Would avoiding clearing the cache still help even if a global property changed? Is this change still useful for MSBuild? |
Unfortunately it's not really useful for MSBuild if that's always the case :( The easy way to test this is to run |
Yeah, we did do some of those before @emgarten improved some of the target perf. For OrchardCore: /t:build /restore /t:restore,build Closing this as redundant right now. |
Bug
Fixes: NuGet/Home#6122
Regression: No
If Regression then when did it last work:
If Regression then how are we preventing it in future:
Fix
Details:
Make restore task report whether the build files changed to optimize double evaluation on build /restore.
It's possible that restore did not happen, yet we save on evaluation if the build assets have not changed.
Right the result is a property that contains the project paths of projects whose assets have changed.
Chatting with @AndyGerlicher to understand if we want the property or we want an item group with more information
Testing/Validation
Tests Added: Yes, only basic tests, can't really test the full integration on our side.
Reason for not adding tests:
Validation done: Manual.