Skip to content

Commit 1bc6550

Browse files
Nigusu-Allehunkolev92jgonz120OliaGdonnie-msft
authored
Publish Main to live (#3397)
* Document package pruning (#3393) * Add doc for ReadmeUriTemplate (#3382) * add new resource doc * Updated the implementation guide * remove extra line * Update URL placeholders to required * Document dotnet tools plugin usage (#3379) * Add README feature description (#3391) * Add files via upload * Update install-use-packages-visual-studio.md * Update docs/consume-packages/install-use-packages-visual-studio.md Co-authored-by: Donnie Goodson <[email protected]> * Update docs/consume-packages/install-use-packages-visual-studio.md Co-authored-by: Donnie Goodson <[email protected]> --------- Co-authored-by: Donnie Goodson <[email protected]> * Add NuGet 6.13 Release Notes (#3390) --------- Co-authored-by: Nikolche Kolev <[email protected]> Co-authored-by: Jonatan Gonzalez <[email protected]> Co-authored-by: Olia Gavrysh <[email protected]> Co-authored-by: Donnie Goodson <[email protected]>
1 parent 01de956 commit 1bc6550

16 files changed

+370
-25
lines changed

docs/TOC.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
#### [Package metadata](api/registration-base-url-resource.md)
129129
#### [Push and delete](api/package-publish-resource.md)
130130
#### [Push symbol packages](api/symbol-package-publish-resource.md)
131+
#### [README URI](api/readme-template-resource.md)
131132
#### [Report abuse URL](api/report-abuse-resource.md)
132133
#### [Repository signatures](api/repository-signatures-resource.md)
133134
#### [Search](api/search-query-service-resource.md)
@@ -185,6 +186,9 @@
185186
### [NU1506](reference/errors-and-warnings/NU1506.md)
186187
### [NU1507](reference/errors-and-warnings/NU1507.md)
187188
### [NU1508](reference/errors-and-warnings/NU1508.md)
189+
### [NU1509](reference/errors-and-warnings/NU1509.md)
190+
### [NU1510](reference/errors-and-warnings/NU1510.md)
191+
### [NU1511](reference/errors-and-warnings/NU1511.md)
188192
### [NU1601](reference/errors-and-warnings/NU1601.md)
189193
### [NU1602](reference/errors-and-warnings/NU1602.md)
190194
### [NU1603](reference/errors-and-warnings/NU1603.md)
@@ -344,6 +348,7 @@
344348
### [Known Issues](release-notes/known-issues.md)
345349

346350
### NuGet 6.x
351+
#### [NuGet 6.13](release-notes/NuGet-6.13.md)
347352
#### [NuGet 6.12](release-notes/NuGet-6.12.md)
348353
#### [NuGet 6.11](release-notes/NuGet-6.11.md)
349354
#### [NuGet 6.10](release-notes/NuGet-6.10.md)

docs/api/implementation-guide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ To assist authors of existing NuGet repositories keep up to date with NuGet's ne
3535
||Added `packageTypes` query parameter to `SearchQueryService` requests|
3636
|2021|[Embedded readme](#embedded-files)|
3737
|2023|[PreAuthenticate authenticated requests](#url-structure-for-authenticated-feeds) <br/> [`VulnerabilityInfo` resource](#known-vulnerabilities-database-vulnerabilityinfo)|
38+
|2025|[Enable embedded README downloads](#enable-embedded-readme-downloads)|
3839

3940
## Owner field
4041

@@ -140,3 +141,7 @@ In this case, every request to the service index will have additional latency, d
140141

141142
While NuGet's V3 API was designed to work on a static file server, the search resource is the exception that always requires a dynamic web service to process requests.
142143
If you wish to host search, or indeed any other NuGet API resource, on different servers, in order to benefit from `HttpClientHandler`'s `PreAuthenticate`, you will need to use a reverse proxy to ensure all customer facing URLs in the service index meet the "same or subdirectory" rule.
144+
145+
## Enable embedded README downloads
146+
147+
A [new resource](./readme-template-resource.md) was documented for constructing a URL that can be used to download a README for a given package. This will allow client, like the Package Management UI in VS, to display the embedded README for packages which haven't been previously installed by the user. The client will construct this URL and attempt to download the README, using the response to the request to determine if a README is available. This means servers should expect multiple requests to the constructed endpoint as users navigate the PM UI.

docs/api/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Resource name | Required
6161
[PackageBaseAddress](package-base-address-resource.md) | yes | Get package content (.nupkg).
6262
[PackageDetailsUriTemplate](package-details-template-resource.md) | no | Construct a URL to access a package details web page.
6363
[PackagePublish](package-publish-resource.md) | yes | Push and delete (or unlist) packages.
64+
[ReadmeUriTemplate](readme-template-resource.md) | no | Construct a URL to access a package's README.
6465
[RegistrationsBaseUrl](registration-base-url-resource.md) | yes | Get package metadata.
6566
[ReportAbuseUriTemplate](report-abuse-resource.md) | no | Construct a URL to access a report abuse web page.
6667
[RepositorySignatures](repository-signatures-resource.md) | no | Get certificates used for repository signing.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: README Uri Template, NuGet API
3+
description: The README uri template allows clients to download the readme for a package, if available.
4+
author: jgonz120
5+
ms.author: jongonza
6+
ms.date: 1/6/2025
7+
ms.topic: reference
8+
ms.reviewer:
9+
---
10+
11+
# README Uri Template
12+
13+
It is possible for a client to build a URL that can be used to download a README for a specific package.
14+
This will enable the clients to render the package's README without downloading the entire package.
15+
16+
The resource used for building this URL is the `ReadmeUriTemplate` resource found in the
17+
[service index](service-index.md).
18+
19+
## Versioning
20+
21+
The following `@type` values are used:
22+
23+
@type value | Notes
24+
--------------------------------- | -----
25+
ReadmeUriTemplate/6.13.0 | The initial release
26+
27+
## URL template
28+
29+
The URL for the following API is the value of the `@id` property associated with one of the aforementioned
30+
resource `@type` values.
31+
32+
## HTTP methods
33+
34+
The constructed URL must support the HTTP method `GET`
35+
36+
## Construct the URL
37+
38+
Given a known package ID and version, the client implementation can construct a URL to download the README.
39+
40+
The value of the `@id` is a URL string containing any of the following placeholder tokens:
41+
42+
### URL placeholders
43+
44+
Name | Type | Required | Notes
45+
----------- | ------- | -------- | -----
46+
`{lower_id}` | string | yes | The package ID, lowercased
47+
`{lower_version}` | string | yes | The package version, lowercased
48+
49+
Both `lower_id` and `lower_version` are lowercased using the rules implemented by .NET's
50+
[`System.String.ToLowerInvariant()`](/dotnet/api/system.string.tolowerinvariant?view=netstandard-2.0#System_String_ToLowerInvariant&preserve-view=true)
51+
method.
52+
53+
The `lower_version` is the desired package version normalized using NuGet's version
54+
[normalization rules](../concepts/package-versioning.md#normalized-version-numbers). This means that build metadata
55+
that is allowed by the SemVer 2.0.0 specification must be excluded in this case.
56+
57+
### Response body
58+
59+
If the package has a readme, a 200 status code is returned. The response body will be the readme
60+
content itself.
61+
62+
If the package does not have a readme, a 404 status code is returned.

docs/consume-packages/Package-References-in-Project-Files.md

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ This may be useful, if you reference projects which are PackageReference styled
6161

6262
## PackageReference and sources
6363

64-
In PackageReference projects, the transitive dependency versions are resolved at restore time. As such, in PackageReference projects all sources need to be available for all restores.
64+
In PackageReference projects, the transitive dependency versions are resolved at restore time. As such, in PackageReference projects all sources need to be available for all restores.
6565

6666
## Floating Versions
6767

@@ -285,7 +285,7 @@ To suppress a warning project wide, consider doing:
285285
</ItemGroup>
286286
```
287287

288-
Sometimes warnings apply only to a certain package in the graph. We can choose to suppress that warning more selectively by adding a `NoWarn` on the PackageReference item.
288+
Sometimes warnings apply only to a certain package in the graph. We can choose to suppress that warning more selectively by adding a `NoWarn` on the PackageReference item.
289289

290290
```xml
291291
<PropertyGroup>
@@ -307,15 +307,15 @@ When in Visual Studio, you can also [suppress warnings](/visualstudio/ide/how-to
307307

308308
Input to NuGet restore is a set of `PackageReference` items from the project file (top-level or direct dependencies) and the output is a full closure of all the package dependencies including transitive dependencies. NuGet tries to always produce the same full closure of package dependencies if the input PackageReference list has not changed. However, there are some scenarios where it is unable to do so. For example:
309309

310-
* When you use floating versions like `<PackageReference Include="My.Sample.Lib" Version="4.*"/>`. While the intention here is to float to the latest version on every restore of packages, there are scenarios where users require the graph to be locked to a certain latest version and float to a later version, if available, upon an explicit gesture.
311-
* A newer version of the package matching PackageReference version requirements is published. E.g.
310+
- When you use floating versions like `<PackageReference Include="My.Sample.Lib" Version="4.*"/>`. While the intention here is to float to the latest version on every restore of packages, there are scenarios where users require the graph to be locked to a certain latest version and float to a later version, if available, upon an explicit gesture.
311+
- A newer version of the package matching PackageReference version requirements is published. E.g.
312312

313-
* Day 1: if you specified `<PackageReference Include="My.Sample.Lib" Version="4.0.0"/>` but the versions available on the
313+
- Day 1: if you specified `<PackageReference Include="My.Sample.Lib" Version="4.0.0"/>` but the versions available on the
314314
NuGet repositories were 4.1.0, 4.2.0 and 4.3.0. In this case, NuGet would have resolved to 4.1.0 (nearest minimum version)
315315

316-
* Day 2: Version 4.0.0 gets published. NuGet will now find the exact match and start resolving to 4.0.0
316+
- Day 2: Version 4.0.0 gets published. NuGet will now find the exact match and start resolving to 4.0.0
317317

318-
* A given package version is removed from the repository. Though nuget.org does not allow package deletions, not all package repositories have this constraint. This results in NuGet finding the best match when it cannot resolve to the deleted version.
318+
- A given package version is removed from the repository. Though nuget.org does not allow package deletions, not all package repositories have this constraint. This results in NuGet finding the best match when it cannot resolve to the deleted version.
319319

320320
### Enabling the lock file
321321

@@ -329,12 +329,13 @@ In order to persist the full closure of package dependencies you can opt-in to t
329329
</PropertyGroup>
330330
```
331331

332-
If this property is set, NuGet restore will generate a lock file - `packages.lock.json` file at the project root directory that lists all the package dependencies.
332+
If this property is set, NuGet restore will generate a lock file - `packages.lock.json` file at the project root directory that lists all the package dependencies.
333333

334334
> [!Note]
335335
> Once a project has `packages.lock.json` file in its root directory, the lock file is always used with restore even if the property `RestorePackagesWithLockFile` is not set. So another way to opt-in to this feature is to create a dummy blank `packages.lock.json` file in the project's root directory.
336336
337337
### `restore` behavior with lock file
338+
338339
If a lock file is present for project, NuGet uses this lock file to run `restore`. NuGet does a quick check to see if there were any changes in the package dependencies as mentioned in the project file (or dependent projects' files) and if there were no changes it just restores the packages mentioned in the lock file. There is no re-evaluation of package dependencies.
339340

340341
If NuGet detects a change in the defined dependencies as mentioned in the project file(s), it re-evaluates the package graph and updates the lock file to reflect the new package closure for the project.
@@ -366,6 +367,7 @@ You may also set this conditional MSBuild property in your project file:
366367
If locked mode is `true`, restore will either restore the exact packages as listed in the lock file or fail if you updated the defined package dependencies for the project after lock file was created.
367368

368369
### Make lock file part of your source repository
370+
369371
If you are building an application, an executable and the project in question is at the start of the dependency chain then do check in the lock file to the source code repository so that NuGet can make use of it during restore.
370372

371373
However, if your project is a library project that you do not ship or a common code project on which other projects depend upon, you **should not** check in the lock file as part of your source code. There is no harm in keeping the lock file but the locked package dependencies for the common code project may not be used, as listed in the lock file, during the restore/build of a project that depends on this common-code project.
@@ -388,7 +390,7 @@ You can control various behaviors of restore with lock file as described below:
388390
| NuGet.exe option | dotnet option | MSBuild equivalent option | Description |
389391
|:--- |:--- |:--- |:--- |
390392
| `-UseLockFile` |`--use-lock-file` | RestorePackagesWithLockFile | Opts into the usage of a lock file. |
391-
| `-LockedMode` | `--locked-mode` | RestoreLockedMode | Enables locked mode for restore. This is useful in CI/CD scenarios where you want repeatable builds.|
393+
| `-LockedMode` | `--locked-mode` | RestoreLockedMode | Enables locked mode for restore. This is useful in CI/CD scenarios where you want repeatable builds.|
392394
| `-ForceEvaluate` | `--force-evaluate` | RestoreForceEvaluate | This option is useful with packages with floating version defined in the project. By default, NuGet restore will not update the package version automatically upon each restore unless you run restore with this option. |
393395
| `-LockFilePath` | `--lock-file-path` | NuGetLockFilePath | Defines a custom lock file location for a project. By default, NuGet supports `packages.lock.json` at the root directory. If you have multiple projects in the same directory, NuGet supports project specific lock file `packages.<project_name>.lock.json` |
394396

@@ -458,3 +460,51 @@ You can leave off `$(AssetTargetFallback)` if you wish to overwrite, instead of
458460
> If you are using a [.NET SDK based project](/dotnet/core/sdk), appropriate `$(AssetTargetFallback)` values are configured and you do not need to set them manually.
459461
>
460462
> `$(PackageTargetFallback)` was an earlier feature that attempted to address this challenge, but it is fundamentally broken and *should* not be used. To migrate from `$(PackageTargetFallback)` to `$(AssetTargetFallback)`, simply change the property name.
463+
464+
## PrunePackageReference
465+
466+
The .NET Runtime is constantly evolving, with performance improvements and new APIs each release.
467+
There is a lot of functionality that's available within the runtime, but also as packages, such as [System..Text.Json](https://www.nuget.org/packages/System.Text.Json). This can often lead to a `System.Text.Json 8.0.0` in a project targeting `.NET 9` or `.NET 8`. This dependency is unnecessary and the build conflict resolution would not use the assembly coming from the package since it's already available in the .NET Runtime.
468+
Starting in in [NuGet version 6.13](..\release-notes\NuGet-6.13.md) and .NET SDK 9.0.200, `PrunePackageReference` enables the pruning of these packages at restore time for .NET SDK based projects.
469+
470+
Package pruning is available as an opt-in feature with the .NET 9 SDK, and will be enabled by default for all `.NET` frameworks and `>= .NET Standard 2.0` starting with .NET 10 SDK.
471+
472+
Package pruning is only available with the default dependency resolver as [released in 6.12](#nuget-dependency-resolver).
473+
474+
### PrunePackageReference specification
475+
476+
The list of packages to be pruned is defined with the `PrunePackageReference` item.
477+
478+
| Attributes | Description |
479+
|------------|-------------|
480+
| Version | Specifies the maximum version to be pruned. `1.0.0` means that all packages up to and including 1.0.0 will be pruned. For `1.0.0`, `0.9.0` and `1.0.0` will be pruned, but `1.0.1` would not. |
481+
482+
The following properties can be used to modify the pruning behavior.
483+
484+
| PropertyName | Description |
485+
|--------------|-------------|
486+
| RestoreEnablePackagePruning | Enables package pruning for the packages specified with `PrunePackageReference`. This property is per target framework and the valid values are `true` and `false`. Defaults may differ based on the .NET SDK as defined above. |
487+
488+
The .NET SDK predefines the list of packages to be pruned for you.
489+
490+
### How PrunePackageReference works
491+
492+
When a package is specified to be pruned during restore, it is removed from the dependency graph. This package is not downloaded and does not appear in any of the outputs of NuGet. When a package is pruned, there is a detailed verbosity message indicating that the package has been removed for the given target framework.
493+
494+
Pruning is only supported for transitive packages, meaning packages that are referenced by other packages or projects. The following table illustrates various package pruning behaviors.
495+
496+
| Dependency disposition | Behavior |
497+
|-----------------|----------|
498+
| Matches the ID of a transitive package coming through another package | Prune |
499+
| Matches the ID of a transitive package coming through another project | Prune |
500+
| Matches the ID of a direct `PackageReference` | Raise the [NU1510](../reference/errors-and-warnings/NU1510.md) warning and do not prune |
501+
| Matches the ID of a `ProjectReference` | Raise the [NU1511](../reference/errors-and-warnings/NU1511.md) warning and do not prune |
502+
503+
### PrunePackageReference applications
504+
505+
The benefits of package pruning are two-fold:
506+
507+
- Performance benefits, by virtue of reducing the number of packages within a dependency graph
508+
- Reduction of false positives by component scanners such as `NuGetAudit`
509+
510+
Pruning is particularly valuable when [auditing](./../concepts/Auditing-Packages.md) packages with `NuGetAuditMode` is set to `all`. If you are using the .NET 9, we recommend you try out pruning by setting `RestoreEnablePackagePruning` to `true`.

docs/consume-packages/install-use-packages-visual-studio.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ To find and install a NuGet package with Visual Studio, follow these steps:
5353

5454
- Select a package to see detailed package information.
5555
The details pane on the right appears and enables you to select a version to install.
56-
![Screenshot showing the NuGet Package Manager window with the Browse tab selected.](media/package-manager-browse-tab.png)
56+
![Screenshot showing the NuGet Package Manager window with the Browse tab, details pane, and "Package Details" tab selected.](media/package-manager-package-details.png)
57+
You can see package metadata, information about the owner(s), author(s), license, etc., in the Package Details tab and the package README file (if it is provided by the package author) in the README tab.
58+
![Screenshot showing the NuGet Package Manager window with the README tab selected.](media/package-manager-package-readme.png)
5759

5860
1. In the right pane, select a **Version** from the dropdown list. If you want to include prerelease versions in the **Version** list, select **Include prerelease**.
5961

234 KB
Loading
354 KB
Loading

docs/reference/Errors-and-Warnings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ NuGet supports the following configuration properties.
4343

4444
| Group | Warning numbers |
4545
| --- | --- |
46-
| Invalid input warnings | [NU1501](./errors-and-warnings/NU1501.md), [NU1502](./errors-and-warnings/NU1502.md), [NU1503](./errors-and-warnings/NU1503.md), [NU1504](./errors-and-warnings/NU1504.md), [NU1505](./errors-and-warnings/NU1505.md), [NU1506](./errors-and-warnings/NU1506.md), [NU1507](./errors-and-warnings/NU1507.md), [NU1508](./errors-and-warnings/NU1508.md) |
46+
| Invalid input warnings | [NU1501](./errors-and-warnings/NU1501.md), [NU1502](./errors-and-warnings/NU1502.md), [NU1503](./errors-and-warnings/NU1503.md), [NU1504](./errors-and-warnings/NU1504.md), [NU1505](./errors-and-warnings/NU1505.md), [NU1506](./errors-and-warnings/NU1506.md), [NU1507](./errors-and-warnings/NU1507.md), [NU1508](./errors-and-warnings/NU1508.md), [NU1509](./errors-and-warnings/NU1509.md), [NU1510](./errors-and-warnings/NU1510.md), [NU1511](./errors-and-warnings/NU1511.md) |
4747
| Unexpected package version warnings | [NU1601](./errors-and-warnings/NU1601.md), [NU1602](./errors-and-warnings/NU1602.md), [NU1603](./errors-and-warnings/NU1603.md), [NU1604](./errors-and-warnings/NU1604.md), [NU1605](./errors-and-warnings/NU1605.md), [NU1606](./errors-and-warnings/NU1108.md), [NU1607](./errors-and-warnings/NU1107.md) |
4848
| Resolver conflict warnings | [NU1608](./errors-and-warnings/NU1608.md) |
4949
| Package fallback warnings | [NU1701](./errors-and-warnings/NU1701.md), [NU1702](./errors-and-warnings/NU1702.md), [NU1703](./errors-and-warnings/NU1703.md)|

0 commit comments

Comments
 (0)