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
{{ message }}
Repository navigation
Commit ff759d8
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: content/actions/tutorials/build-and-test-code/net.md
+35-20Lines changed: 35 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,7 +145,21 @@ steps:
145
145
146
146
### Caching dependencies
147
147
148
-
You can cache NuGet dependencies for future workflows using the optional `cache` input. For example, the YAML below caches the NuGet `global-packages` folder, and then installs the `Newtonsoft` package. A second optional input, `cache-dependency-path`, can be used to specify the path to a dependency file: `packages.lock.json`.
148
+
You can cache NuGet dependencies for future workflows using the optional `cache` input. Caching requires a `packages.lock.json` file. If the action cannot find a matching lock file, it fails.
149
+
150
+
Before enabling caching:
151
+
152
+
1. In the directory containing your project or solution, generate the lock files locally.
153
+
154
+
```shell
155
+
dotnet restore --use-lock-file
156
+
```
157
+
158
+
1. Commit the generated `packages.lock.json` files to your repository so they are available when the workflow runs.
159
+
160
+
For more information, see [Locking dependencies](https://learn.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies) in the NuGet documentation.
161
+
162
+
By default, `setup-dotnet` looks for a lock file in the repository root. Use `cache-dependency-path` to specify lock files in subdirectories or multiple lock files. The following example caches the NuGet `global-packages` folder using lock files throughout the repository, then restores the dependencies in locked mode.
149
163
150
164
For more information, see [AUTOTITLE](/actions/reference/workflows-and-actions/dependency-caching).
0 commit comments