-
Notifications
You must be signed in to change notification settings - Fork 255
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
dotnet list package checks if restore is current #14065
base: dev
Are you sure you want to change the base?
Conversation
Thank you @zivkan for the ideas in our offline discussion. |
<!-- Why is this the best design compared to other designs? --> | ||
<!-- What other designs have been considered and why weren't they chosen? --> | ||
<!-- What is the impact of not doing this? --> | ||
- **Force Restore Every Time**: Automatically run restore when dotnet list package is 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.
I think this should say "Implicitly run restore which might do a no-op with an option to disable via a command-line argument --no-restore
which other commands have. This would probably be me vote personally.
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.
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.
fwiw, as per the spec guide, I think we should make a good argument about why we're not pursuing certain alternative.
In this case, those drawbacks are not obvious.
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.
Spec looks great, complete and there's plenty of technical detail.
We should explore @jeffkl's idea and get a sense of whether we'd want to make that breaking change (or if we've explored it in more detail, we should details about why we're not pursuing that direction.
<!-- Why is this the best design compared to other designs? --> | ||
<!-- What other designs have been considered and why weren't they chosen? --> | ||
<!-- What is the impact of not doing this? --> | ||
- **Force Restore Every Time**: Automatically run restore when dotnet list package is 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.
<!-- Why is this the best design compared to other designs? --> | ||
<!-- What other designs have been considered and why weren't they chosen? --> | ||
<!-- What is the impact of not doing this? --> | ||
- **Force Restore Every Time**: Automatically run restore when dotnet list package is 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.
fwiw, as per the spec guide, I think we should make a good argument about why we're not pursuing certain alternative.
In this case, those drawbacks are not obvious.
To me, it seems like the |
That is a great point. Currently the following is the counter argument to that: The discussed here #13406 (comment) |
Thinking about this more, I'm imagine any scenario where my project XML just has: <ItemGroup>
<PackageReference Include="SomePackage" Version="1.0.0" />
</ItemGroup> I run What does that same scenario in Visual Studio feel like? Implicit restore is on by default but if I turn it off, does PM UI show me what was previously restored? Does it prompt me to manually restore before it will show me the packages? I struggle because I defined my packages in XML and saved the file. To me, The offline scenario is potentially something to care about of course. But if I restore my project by simply building it or loading it in Visual Studio, the restore already happened and subsequent implicit restores with The real question that I'm interested in knowing the answer to is: How many actual users would experience a negative experience if we changed Is that impact broad? If those users could just update their script with a |
PM UI shows a banner that "Some packages are missing" and offers a Restore gesture. An action (say, Update a package) still triggers restore regardless of whether the setting is disabled. Not sure if this is by design or a bug when an action triggers the restore versus a build. I believe PM UI is already aligning with your suggestion for |
|
||
The `dotnet list package` command is used to list packages referenced by a project, but it requires a restore operation to be performed beforehand to ensure accurate information. NuGet currently checks for the existence of an assets file to assert that restore has been performed. | ||
However, if a user modifies the project file after running restore, the assets file may become outdated, leading to misinformation from the dotnet list package command. | ||
This proposal discusses how to ensure that NuGet asserts the assets file is in sync with the project file to prevent such issues |
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.
Feels like this should actually call out the proposal.
|
||
## Summary | ||
|
||
The `dotnet list package` command is used to list packages referenced by a project, but it requires a restore operation to be performed beforehand to ensure accurate information. NuGet currently checks for the existence of an assets file to assert that restore has been performed. |
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.
The `dotnet list package` command is used to list packages referenced by a project, but it requires a restore operation to be performed beforehand to ensure accurate information. NuGet currently checks for the existence of an assets file to assert that restore has been performed. | |
The `dotnet list package` command is used to list packages referenced by a project, but it requires a restore operation to be performed beforehand to ensure accurate information. | |
NuGet currently checks for the existence of an assets file to assert that restore has been performed. |
inconsistent new lines per sentence
|
||
The `dotnet list package` command is used to list packages referenced by a project, but it requires a restore operation to be performed beforehand to ensure accurate information. NuGet currently checks for the existence of an assets file to assert that restore has been performed. | ||
However, if a user modifies the project file after running restore, the assets file may become outdated, leading to misinformation from the dotnet list package command. | ||
This proposal discusses how to ensure that NuGet asserts the assets file is in sync with the project file to prevent such issues |
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.
This proposal discusses how to ensure that NuGet asserts the assets file is in sync with the project file to prevent such issues | |
This proposal discusses how to ensure that NuGet asserts the assets file is in sync with the project file to prevent such issues. |
nitpick 🤣
## Summary | ||
|
||
The `dotnet list package` command is used to list packages referenced by a project, but it requires a restore operation to be performed beforehand to ensure accurate information. NuGet currently checks for the existence of an assets file to assert that restore has been performed. | ||
However, if a user modifies the project file after running restore, the assets file may become outdated, leading to misinformation from the dotnet list package command. |
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.
However, if a user modifies the project file after running restore, the assets file may become outdated, leading to misinformation from the dotnet list package command. | |
However, if a user modifies the project file, or a ProjectReference's project file, after running restore, the assets file may become outdated, leading to misinformation from the dotnet list package command. |
packages are transitive
Before this command is executed, users are expected to perform a restore operation. | ||
NuGet expects restore to be run both after project creation and every time a change has been made to the project. |
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.
nitpick: The first sentence is basically a less detailed duplicate of the second sentence. So one of these can be deleted.
|
||
<!-- Explain the proposal in sufficient detail with implementation details, interaction models, and clarification of corner cases. --> | ||
|
||
Comparing the contents of the project file and the assets file is the most important step here. We will achieve this by using no-op restore. |
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.
Comparing the contents of the project file and the assets file is the most important step here. We will achieve this by using no-op restore. | |
Comparing the contents of the project file and the assets file is the most important step here. | |
We will achieve this by using no-op restore. |
One sentence per line 😁
Comparing the contents of the project file and the assets file is the most important step here. We will achieve this by using no-op restore. | ||
|
||
- Create a DGSpec file from the evaluated project | ||
- To create the DGSpec file, use an MSBuild target, [GenerateRestoreGraphFile](https://github.com/NuGet/NuGet.Client/blob/cb0b5561f4fd98347cedac11919f769da0b767f4/src/NuGet.Core/NuGet.Build.Tasks/NuGet.RestoreEx.targets#L46), that writes the DGSpec to a file and then load it. |
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 I've given this feedback on a number of feature specs, but I think this is too much detail for a feature or design spec.
My concern is that some people find these design specs, wrongly assume they're still current, even years after they're written or implemented, and then assume that any behaviour differences are a bug.
The first implementation might run msbuild as a child process to run this target, but this has a flaw when trying to get a PackageSpec or DGSpec, but I'm working on making it easier for all NuGet's dotnet *
commands to create a DGSpec programatically, in-process. Depending on the timing of the two workstreams, maybe dotnet list package
will not need to use this msbuild target.
Basically, I think it's sufficient to give the "high level" overview of how we'll detect if the restore is up to date, which is to use the same logic as no-op restores. How we achieve the no-op restore check is an implementation detail that is subject to change over time.
|
||
Log the following | ||
|
||
> Error: The project's dependency graph has been altered. Please perform a restore for project '{0}'. |
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 don't think "The project's dependency graph has been altered" makes any sense to customers. The DGSpec is a NuGet internal implementation detail, that even expert customers have no need to know about.
A more friendly message would be something like "The project has been modified since the last restore"
|
||
## Prior Art | ||
|
||
<!-- What prior art, both good and bad are related to this proposal? --> |
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.
- VS restores automatically on solution load for SDK style projects, or before every build for all other projects
dotnet build
,dotnet publish
, anddotnet test
all restore automatically by default, unless--no-restore
is provided- installing or upgrading packages either in VS or with
dotnet add package
, restores the project, in addition to modifying project files.dotnet add package
has a--no-restore
option.
Rendered: https://github.com/NuGet/Home/blob/e767bd9abb67589d3892b1382f70e8fc72a8ca13/accepted/2025/dotnet-list-package-restore-no-op-check.md