Skip to content

Commit 65ce618

Browse files
pragnya17BillWagnertdykstra
authored
Added dotnet add package CPM support documentation (#30496)
* update with added CPM support documentation * Apply suggestions from code review Co-authored-by: Tom Dykstra <[email protected]> --------- Co-authored-by: Bill Wagner <[email protected]> Co-authored-by: Tom Dykstra <[email protected]>
1 parent f535742 commit 65ce618

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

docs/core/tools/dotnet-add-package.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,74 @@ The *ToDo.csproj* file now contains a [`<PackageReference>`](/nuget/consume-pack
5151
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.4" />
5252
```
5353

54+
If the project is onboarded onto [Central Package Management (CPM)](https://devblogs.microsoft.com/nuget/introducing-central-package-management/) the `<PackageVersion>` element in the `Directory.Packages.props file` is added/updated and the `<PackageReference>` element is added to the project file.
55+
56+
The following scenarios are currently supported. These examples assume that the latest version of `Microsoft.EntityFrameworkCore` is 6.0.4. Additional scenarios related to CPM are documented in [this design spec](https://github.com/NuGet/Home/pull/11915).
57+
58+
Scenario 1: `<PackageReference>` does not exist in the project file, `<PackageVersion>` element does not exist in the `Directory.Packages.props file`, and the version argument is not passed from the commandline.
59+
60+
CLI command that is executed: `dotnet add ToDo.csproj package Microsoft.EntityFrameworkCore`
61+
62+
The `<PackageVersion>` element is added to the `Directory.Packages.props file`.
63+
64+
```xml
65+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="6.0.4" />
66+
```
67+
68+
The `<PackageReference>` element is added to the project file.
69+
70+
```xml
71+
<PackageReference Include="Microsoft.EntityFrameworkCore" />
72+
```
73+
74+
Scenario 2: `<PackageReference>` does not exist in the project file, `<PackageVersion>` element does not exist in the `Directory.Packages.props file`, and the version argument is passed from the commandline.
75+
76+
CLI command that is executed: `dotnet add ToDo.csproj package Microsoft.EntityFrameworkCore --version 5.0.4`
77+
78+
The `<PackageVersion>` element is added to the `Directory.Packages.props file`.
79+
80+
```xml
81+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="5.0.4" />
82+
```
83+
84+
The `<PackageReference>` element is added to the project file.
85+
86+
```xml
87+
<PackageReference Include="Microsoft.EntityFrameworkCore" />
88+
```
89+
90+
Scenario 3: `<PackageReference>` does not exist in the project file, `<PackageVersion>` element does exist in the `Directory.Packages.props file`, and the version argument is not passed from the commandline.
91+
92+
CLI command that is executed: `dotnet add ToDo.csproj package Microsoft.EntityFrameworkCore`
93+
94+
The `<PackageVersion>` element is added to the `Directory.Packages.props file`.
95+
96+
```xml
97+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="6.0.4" />
98+
```
99+
100+
The `<PackageReference>` element is added to the project file.
101+
102+
```xml
103+
<PackageReference Include="Microsoft.EntityFrameworkCore" />
104+
```
105+
106+
Scenario 4: `<PackageReference>` does not exist in the project file, `<PackageVersion>` element does exist in the `Directory.Packages.props file`, and the version argument is passed from the commandline.
107+
108+
CLI command that is executed: `dotnet add ToDo.csproj package Microsoft.EntityFrameworkCore --version 5.0.4`
109+
110+
The `<PackageVersion>` element is added to the `Directory.Packages.props file`.
111+
112+
```xml
113+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="5.0.4" />
114+
```
115+
116+
The `<PackageReference>` element is added to the project file.
117+
118+
```xml
119+
<PackageReference Include="Microsoft.EntityFrameworkCore" />
120+
```
121+
54122
### Implicit restore
55123

56124
[!INCLUDE[DotNet Restore Note](../../../includes/dotnet-restore-note.md)]

0 commit comments

Comments
 (0)