Skip to content

Commit d45e66e

Browse files
authored
Initial docs for dotnet package update (#48884)
1 parent 8414810 commit d45e66e

File tree

3 files changed

+120
-1
lines changed

3 files changed

+120
-1
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: dotnet package update command
3+
description: Update PackageReferences in a project.
4+
author: zivkan
5+
ms.date: 10/03/2025
6+
---
7+
# dotnet package update
8+
9+
**This article applies to:** ✔️ .NET 10 SDK and later versions
10+
11+
## Name
12+
13+
`dotnet package update` - Update referenced packages in a project.
14+
15+
## Synopsis
16+
17+
```dotnetcli
18+
dotnet package update [<packages>...]
19+
[--interactive] [--project <path>]
20+
[--verbosity <level>] [--vulnerable]
21+
22+
dotnet package update -h|--help
23+
```
24+
25+
## Description
26+
27+
The `dotnet package update` command updates packages used by projects.
28+
If [NuGetAudit](/nuget/concepts/auditing-packages) is enabled, it can also attempt to automatically update update packages with known vulnerabilities to fixed versions.
29+
30+
### Warnings as Errors
31+
32+
`dotnet package update` does implicit restores to check if the resulting package graph is free of errors.
33+
Using `--vulnerable` also does an implicit restore to find NuGetAudit warnings.
34+
However, if your project uses `WarningsAsErrors` or `TreatWarningsAsErrors`, NuGet's restore warnings can cause restore to fail, preventing the update from completing.
35+
36+
We recommend taking advantage of MSBuild conditions and environment variables as a workaround until [this feature request](https://github.com/NuGet/Home/issues/14311) is implemented.
37+
For example, set `<TreatWarningsAsErrors Condition=" '$(CustomCondition)' == ''>true</TreatWarningsAsErrors>` in your project, and then on most Linux and Mac shells you can run `CustomCondition=true dotnet package update`.
38+
On Windows Command Prompt and PowerShell, you will need to set the environment variable, run dotnet package update, then unset the environment variable as three separate commands.
39+
40+
## Arguments
41+
42+
- **`packages`**
43+
44+
An optional list of packages to update.
45+
When no packages are provided, the command will attempt to update all packages referenced by the project.
46+
Packages can be a package name optionally followed by an `@` and a version number.
47+
For example, `dotnet package update Contoso.Utilities` or `dotnet package update Contoso.Utilities@3.2.1`.
48+
When no version is provided, it will find the highest version available on the configured package sources.
49+
50+
## Options
51+
52+
- **`--interactive`**
53+
54+
Allows the command to stop and wait for user input or action (for example to complete authentication).
55+
56+
- **`--project <path>`**
57+
58+
The project which packages should be updated in.
59+
If a directory is provided, it searches for project and solution files in the directory.
60+
Defaults to the current working directory.
61+
62+
- **`--verbosity`**
63+
64+
Display this amount of details in the output: `[n]ormal`, `[m]inimal`, `[q]uiet`, `[d]etailed`, or `[diag]nostic`. The default is `normal`.
65+
66+
- **`--vulnerable`**
67+
68+
If restore reports any packages as having known vulnerabilities, this command will upgrade those packages.
69+
Using this option will upgrade packages to the lowest version that is higher than the currently referenced version, that does not have any known vulnerabilities.
70+
71+
[!INCLUDE [help](../../../includes/cli-help.md)]
72+
73+
## Examples
74+
75+
- Update all packages in the project to the highest version available
76+
77+
```dotnetcli
78+
dotnet package update
79+
```
80+
81+
```output
82+
Updating outdated packages in S:\src\test\update\ConsoleApp1.
83+
ConsoleApp1:
84+
Updated Microsoft.Extensions.Configuration 9.0.0 to 9.0.9.
85+
Updated Microsoft.Extensions.DependencyInjection 9.0.0 to 9.0.9.
86+
87+
Updated 2 packages in 7 scanned packages.
88+
```
89+
90+
- Update Contoso.Utilities to the highest version available, and Fabrikam.WebApi to version 1.2.3
91+
92+
```dotnetcli
93+
dotnet package update Contoso.Utilities Fabrikam.WebApi@1.2.3
94+
```
95+
96+
```output
97+
Updating outdated packages in S:\src\test\update\ConsoleApp1.
98+
ConsoleApp1:
99+
Updated Contoso.Utilities 2.3.1 to 2.4.6.
100+
Updated Fabrikam.WebApi 1.0.2 to 1.2.3.
101+
102+
Updated 2 packages in 2 scanned packages.
103+
```
104+
105+
- Update packages with known vulnerabilities
106+
107+
```dotnetcli
108+
dotnet package update --vulnerable
109+
```
110+
111+
```output
112+
Updating packages with security advisories in S:\src\test\update\ConsoleApp1
113+
ConsoleApp1:
114+
Updating System.Text.Json 8.0.0 to 8.0.5.
115+
116+
Updated 1 packages in 31 scanned packages.
117+
```

docs/core/tools/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ The following commands are installed by default:
7878
- [`package list`](dotnet-package-list.md)
7979
- [`package remove`](dotnet-package-remove.md)
8080
- [`package search`](dotnet-package-search.md)
81+
- [`package update`](dotnet-package-update.md)
8182
- [`reference add`](dotnet-reference-add.md)
8283
- [`reference list`](dotnet-reference-list.md)
8384
- [`reference remove`](dotnet-reference-remove.md)
@@ -96,7 +97,6 @@ The following commands are installed by default:
9697
- [`nuget verify`](dotnet-nuget-verify.md) (Available since .NET 5 SDK)
9798
- [`nuget trust`](dotnet-nuget-trust.md) (Available since .NET 5 SDK)
9899
- [`nuget sign`](dotnet-nuget-sign.md) (Available since .NET 6 SDK)
99-
- [`package search`](dotnet-package-search.md) (Available since .NET 8.0.2xx SDK)
100100
- [`nuget why`](dotnet-nuget-why.md) (Available since .NET 8.0.4xx SDK)
101101

102102
### Workload management commands

docs/navigate/tools-diagnostics/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ items:
190190
href: ../../core/tools/dotnet-package-remove.md
191191
- name: dotnet package search
192192
href: ../../core/tools/dotnet-package-search.md
193+
- name: dotnet package update
194+
href: ../../core/tools/dotnet-package-update.md
193195
- name: dotnet publish
194196
href: ../../core/tools/dotnet-publish.md
195197
- name: dotnet reference add/list/remove

0 commit comments

Comments
 (0)