You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/archive/project-json-and-uwp.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,8 @@ ms.topic: conceptual
10
10
# project.json and UWP
11
11
12
12
> [!Important]
13
-
> This content is deprecated. Projects should use either the `packages.config` or PackageReference formats.
13
+
> This content is deprecated. Projects should use the PackageReference formats.
14
+
> Learn how to [migrate your project.json project to PackageReference](./project-json.md#migrate-projectjson-to-packagereference).
14
15
15
16
This document describes the package structure that employs features in NuGet 3+ (Visual Studio 2015 and later). The `minClientVersion` property of your `.nuspec` can be used to state that you require the features described here by setting it to 3.1.
Copy file name to clipboardExpand all lines: docs/archive/project-json.md
+15-2Lines changed: 15 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,10 @@ ms.topic: reference
10
10
# project.json reference
11
11
12
12
> [!Important]
13
-
> This content is deprecated. Projects should use either the `packages.config` or PackageReference formats.
13
+
> This content is deprecated. Projects should use the PackageReference formats.
14
+
> Learn how to [migrate your project.json project to PackageReference](#migrate-projectjson-to-packagereference).
14
15
15
-
*NuGet 3.x+*
16
+
*NuGet 3.x*
16
17
17
18
The `project.json` file maintains a list of packages used in a project, known as a package management format. It supersedes `packages.config` but is in turn superseded by [PackageReference](../consume-packages/package-references-in-project-files.md) with NuGet 4.0+.
18
19
@@ -37,6 +38,18 @@ The [`project.lock.json`](#projectlockjson) file (described below) is also used
37
38
}
38
39
```
39
40
41
+
## Migrate project.json to PackageReference
42
+
43
+
The migration between project.json and PackageReference is straightforward. The easiest way to do it to use the built-in migrator in the latest Visual Studio 2022, Update 14.
44
+
45
+
1. Load the project.json project in Visual Studio.
46
+
1. Go to the solution explorer of the project.json project and find the dependencies node.
47
+
1. Click `Migrate project.json to PackageReference...`!
48
+
49
+

50
+
51
+
Alternatively, you may use the [dotnet migrate](/dotnet/core/tools/dotnet-migrate), or do the migration manually by taking all of the content from the project.json file and replacing it with the equivalent [PackageReference syntax](../consume-packages/Package-References-in-Project-Files.md).
52
+
40
53
## Dependencies
41
54
42
55
Lists the NuGet package dependencies of your project in the following form:
Copy file name to clipboardExpand all lines: docs/concepts/Dependency-Resolution.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,7 @@ When using a floating version, NuGet resolves the highest version of a package t
63
63
| 1.1.*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.2.0-alpha | 1.1.1 | The highest stable version that respects the specified pattern.|
64
64
|\*-\*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.3.0-beta | 1.3.0-beta | The highest version including the not stable versions. | Available in Visual Studio version 16.6, NuGet version 5.6, .NET Core SDK version 3.1.300 |
65
65
| 1.1.\*-\*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.1.2-beta <br> 1.3.0-beta | 1.1.2-beta | The highest version respecting the pattern and including the not stable versions. | Available in Visual Studio version 16.6, NuGet version 5.6, .NET Core SDK version 3.1.300 |
66
+
| 1.2.0-rc.*| 1.1.0 <br> 1.2.0-rc.1 <br> 1.2.0-rc.2 <br> 1.2.0 | 1.2.0 | Despite this being a version range with a prerelease part, stables are allowed if they match the stable part. Given that 1.2.0 > 1.2.0-rc.2, it is chosen. ||
66
67
67
68
> [!Note]
68
69
> Floating version resolution does not take into account whether or not a package is listed.
Copy file name to clipboardExpand all lines: docs/consume-packages/Central-Package-Management.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,11 @@ Central package management applies to all `<PackageReference>`-based MSBuild pro
38
38
To get started with central package management, you must create a `Directory.Packages.props` file at the root of your repository and set the MSBuild property
39
39
`ManagePackageVersionsCentrally` to `true`.
40
40
41
+
You can create it manually or you can use the dotnet CLI:
42
+
```shell
43
+
dotnet new packagesprops
44
+
```
45
+
41
46
Inside, you then define each of the respective package versions required of your projects using `<PackageVersion />` elements that define the package ID and
42
47
version.
43
48
@@ -117,6 +122,7 @@ For an idea of how central package management may look like, refer to our [sampl
117
122
118
123
You can automatically override a transitive package version even without an explicit top-level `<PackageReference />` by opting into a feature known as
119
124
transitive pinning. This promotes a transitive dependency to a top-level dependency implicitly on your behalf when necessary.
125
+
Note that downgrades are allowed when transitive pinning a package. If you attempt to pin a package to a lower version than the one requested by your dependencies, restore will raise a [NU1109](../reference/errors-and-warnings/NU1109.md) error.
120
126
121
127
You can enable this feature by setting the MSBuild property `CentralPackageTransitivePinningEnabled` to `true` in a project or in a `Directory.Packages.props`
122
128
or `Directory.Build.props` import file:
@@ -127,6 +133,45 @@ or `Directory.Build.props` import file:
127
133
</PropertyGroup>
128
134
```
129
135
136
+
### Transitive pinning and pack
137
+
138
+
When a package is transitively pinned, your project uses a higher than the one requested by your dependencies.
139
+
If you create a package from your project, in order to ensure that your package will work, NuGet will promote the transitively pinned dependencies to explicit dependencies in the nuspec.
140
+
141
+
In the following example, `PackageA 1.0.0` has a dependency on `PackageB 1.0.0`.
Because of this, the use of transitive pinning should be carefully evaluated when authoring a library as it may lead to dependencies you did not expect.
174
+
130
175
## Overriding package versions
131
176
132
177
You can override an individual package version by using the `VersionOverride` property on a `<PackageReference />` item. This overrides any `<PackageVersion />`
@@ -176,6 +221,7 @@ If you'd like to disable central package management for any a particular project
176
221
```
177
222
178
223
## Global Package References
224
+
179
225
> [!Note]
180
226
> This feature is only available in Visual Studio 2022 17.4 or higher, .NET SDK 7.0.100.preview7 or higher, and NuGet 6.4 or higher.
Copy file name to clipboardExpand all lines: docs/hosting-packages/Overview.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,5 +39,6 @@ There are also several other NuGet hosting products such as [Azure Artifacts](ht
39
39
-[ProGet](https://inedo.com/proget) from Inedo
40
40
-[Sleet](https://github.com/emgarten/sleet), an open-source NuGet V3 static feed generator
41
41
-[TeamCity](https://www.jetbrains.com/teamcity/) from JetBrains.
42
+
-[RepoFlow](https://www.repoflow.io), a simple and easy-to-use package management platform.
42
43
43
44
Regardless of how packages are hosted, you access them by adding them to the list of available sources in `NuGet.Config`. This can be done in Visual Studio as described in [Package Sources](../consume-packages/install-use-packages-visual-studio.md#package-sources), or from the command line using [`nuget sources`](../reference/cli-reference/cli-ref-sources.md). The path to a source can be a local folder pathname, a network name, or a URL.
0 commit comments