-
Notifications
You must be signed in to change notification settings - Fork 420
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
Implement package auto-restore for .csproj projects #747
Conversation
… and implement package auto-restore for .csproj projects
IEnumerable<PackageReference> unresolvedPackageReferences; | ||
|
||
// Did the project file change? Diff the package references and see if there are unresolved dependencies. | ||
if (previousProjectFileInfo != null) |
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 be really good if NuGet.ProjectModel provided some API for these types of checks
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.
Which checks? These are the package references defined in the .csproj. NuGet provides no APIs for the .csproj file itself.
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.
oh, there is no API in nuget for reading package references from csproj? I didn't realize that
(there used to be APIs for reading references from packages.config
and to read references from project.json
)
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.
Nope. The API for reading from .csproj is MSBuild. 😄
|
||
namespace OmniSharp.MSBuild.ProjectFile | ||
{ | ||
public class PackageReference : IEquatable<PackageReference> |
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.
nuget has this https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.PackageManagement/Utility/PackageReferenceComparer.cs, maybe there is no need to introduce a class into omnisharp?
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.
Possibly. I believe these are used by NuGet to handle VS package restore, which is a much bigger thing than what we're doing. I just need to keep a list of the PackageReferences items computed by MSBuild so that I can tell if changes occurred to the project file. This is before NuGet is really involved.
Note that this class is not exactly the same. It has at least one piece of additional metadata that is provided via MSBuild targets.
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.
Note: NuGet's PackageReference is way different: https://github.com/NuGet/NuGet.Client/blob/4cccb13833ad29d6a0bcff055460d964f1b49cfe/src/NuGet.Core/NuGet.Packaging/PackageReference.cs. These aren't the same thing.
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.
right now I remember, in the past I used to define my own PackageReference
on the old nuget apis too, for the very same reason you just mentioned
Fixes dotnet/vscode-csharp#770