Skip to content
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

Changing active configuration should not trigger restore cycle detection #9567

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Oct 25, 2024

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1951646

We have a feature that attempts to detect patterns in NuGet restore data, flagging these as a runaway restore cycle, stopping the cyclic behaviour, and alerting the user.

Test teams found a scenario where continuously changing active configuration (i.e. toggling between Debug and Release several times) would trigger the cycle detection logic incorrectly. This was causing failures in automated test runs.

This only happens when restore data differs between configurations. A new console app with some simple packages added does not trigger this. The .NET Project System repo would, however.

This commit fixes the issue by including the active project configuration in the dataflow data, such that the cycle detector resets its state whenever the active configuration changes.

Microsoft Reviewers: Open in CodeFlow

@drewnoakes drewnoakes added the Feature-NuGet NuGet integration including pushing it properties, project and package references, and Pack support. label Oct 25, 2024
@drewnoakes drewnoakes requested a review from a team as a code owner October 25, 2024 02:26
@drewnoakes
Copy link
Member Author

Build failure fixed in #9568. Will rebase when that merges.

Prevent potential collection corruption
We have a feature that attempts to detect patterns in NuGet restore data, flagging these as a runaway restore cycle, stopping the cyclic behaviour, and alerting the user.

Test teams found a scenario where continuously changing active configuration (i.e. toggling between Debug and Release several times) would trigger the cycle detection logic incorrectly.

This only happens when restore data differs between configurations. A new console app with some simple packages added does not trigger this. The .NET Project System repo would, however.

This commit fixes the issue by including the active project configuration in the dataflow data, such that the cycle detector resets its state whenever the active configuration changes.
@drewnoakes drewnoakes force-pushed the fix-1951646-changing-configuration-does-not-cause-restore-cycle branch from 4ce15fa to 9773e52 Compare October 25, 2024 04:51
Comment on lines +55 to +64
_priorActiveProjectConfiguration ??= activeProjectConfiguration;

if (!Equals(_priorActiveProjectConfiguration, activeProjectConfiguration))
{
// The active configuration changed. Treat this as a reset. This prevents flagging a
// cycle when the user switches configurations repeatedly in certain repositories.
_priorActiveProjectConfiguration = activeProjectConfiguration;
Reset();
return false;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the core fix. If the active configuration changes, clear all state in our detection logic. Most of the other changes in this PR exist to support this code.

@drewnoakes drewnoakes merged commit f635181 into dotnet:main Nov 14, 2024
5 checks passed
@drewnoakes drewnoakes deleted the fix-1951646-changing-configuration-does-not-cause-restore-cycle branch November 14, 2024 22:01
@dotnet-policy-service dotnet-policy-service bot added this to the 17.12 milestone Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-NuGet NuGet integration including pushing it properties, project and package references, and Pack support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants