Repository navigation
Conversation
7c0188c to
a331f78
Compare
c2074f5 to
e83381a
Compare
nkolev92
left a comment
There was a problem hiding this comment.
Great job so far.
A few suggestions to improve clarity and I think we might be missing some scenarios.
nkolev92
left a comment
There was a problem hiding this comment.
This is looking great!
Let's add some no-op and negative tests.
In particular:
What if I specify a --version where the PackageVersion is already in the DBP.
We should no-op in this case, or do whatever the dotnet add package --version command does on a standard PackageReference project.
Think about the no-op version of every scenario you implemented.
6236de4 to
48834f8
Compare
8455b4f to
9c4e593
Compare
I assume that by DBP you mean the Directory.Build.props file? However, in the scenarios that I have implemented I assume that the DBP does not exist since it is out of the scope of my project. In this comment, Jeff also mentions that the Directory.Packages.props file is mandatory for onboarding to CPM: NuGet/Home#11903 (comment) . I am happy to create a follow up work item to ensure that we fallback onto existing behavior for the scenario where the Directory.Packages.props file does not exist. |
|
I meant to write if the version is already in DPP (Directory.Packages.props). I don't really care about the scenarios where the project is not onboarded. |
Makes sense. I actually did already handle the scenario you were talking about (#4700 (review)), I just did not name it properly, so I have now updated the name of the test. For the first 4 scenarios that I implemented, after discussing with @kartheekp-ms and reviewing the spec again (https://github.com/NuGet/Home/blob/dev-kartheekp-ms-cpmaddpackagesupport-revised/proposed/2022/cpm-dotnet-cli-add-package-support.md), I don't believe there are any other no-op/fail scenarios that need to be included in the integration tests. |
kartheekp-ms
left a comment
There was a problem hiding this comment.
Great job. I know CI is failing on other platforms. I will create a separate issue to track that work. Given that this work is getting merged into a feature branch, I will fix the CI scripts before creating a new pull request for merging these changes into the dev branch.
| Assert.Contains(@$"<PackageReference Include=""X"" />", File.ReadAllText(Path.Combine(testDirectory, "projectA.csproj"))); | ||
| Assert.DoesNotContain(@$"<Version = ""1.0.0"" />", File.ReadAllText(Path.Combine(testDirectory, "projectA.csproj"))); |
There was a problem hiding this comment.
I think we can slightly improve the performance by reading text from the project only once.
There was a problem hiding this comment.
Agreed, will fix that.
|
@pragnya17 - I have updated |
| Assert.DoesNotContain(@$"<Version = ""1.0.0"" />", File.ReadAllText(Path.Combine(testDirectory, "projectA.csproj"))); | ||
| string updatedProjectFile = File.ReadAllText(Path.Combine(testDirectory, "projectA.csproj")); | ||
| Assert.Contains(@$"<PackageReference Include=""X"" />", updatedProjectFile); | ||
| Assert.DoesNotContain(@$"<Version = ""1.0.0"" />", updatedProjectFile); |
There was a problem hiding this comment.
This always return true, so I think it should be changed to $"PackageReference Includes =""X"" <Version = ""1.0.0"" />". This is along the lines of this comment: #4700 (comment)
* dotnet add package cli support for cpm projects (#4700)
* dotnet add package cli support for cpm projects (#4700) Co-authored-by: pragnya17 <59893188+pragnya17@users.noreply.github.com>
* dotnet add package cli support for cpm projects (#4700)
Bug
Fixes: NuGet/Home#11890
Regression? No.
Description
This feature is based on the design spec: NuGet/Home#11915. The goal was to allow the dotnet add package command to be executed for projects that were onboarded to CPM. Previously, the command threw a NU1008 error whenever packages were attempted to be added to projects onboarded to CPM. However, with this change users will now be able to add or update package references in projects onboarded to CPM. Directory.Packages.props files and project files are now modified accordingly whenever a package is added/updated.
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation