Linux command
dotnet-restore 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Restore
dotnet restore
Restore a specific project
dotnet restore [project.csproj]
Restore from a specific NuGet source
dotnet restore --source [https://api.nuget.org/v3/index.json]
Restore without using HTTP cache
dotnet restore --no-cache
Restore for a specific runtime
dotnet restore --runtime [linux-x64]
Restore in lock-file mode
dotnet restore --locked-mode
Restore with verbose logging
dotnet restore --verbosity detailed
说明
dotnet restore downloads and installs all NuGet package dependencies declared in a project, solution, or dotnet-tools.json. It reads PackageReference entries from .csproj/.fsproj/.vbproj files, queries the configured NuGet sources, and writes restored assets to obj/project.assets.json. Other commands like dotnet build and dotnet run trigger an implicit restore by default, so explicit invocation is mainly useful in CI pipelines (where you want to cache the restore step), when troubleshooting package resolution, or when --no-restore is being used downstream.
参数
- -s, --source _SOURCE_
- NuGet package source to use during restore (overrides nuget.config).
- --packages _DIR_
- Directory in which to install the restored packages (default: ~/.nuget/packages).
- --no-cache
- Don't cache HTTP requests; always re-fetch from the source.
- --no-dependencies
- Restore only the root project, ignoring project-to-project references.
- --force
- Force all dependencies to be re-resolved even if a cached lock exists.
- --locked-mode
- Don't allow updates to packages.lock.json — fail if it would change.
- --use-lock-file
- Generate or update packages.lock.json.
- --runtime _RID_
- Target a specific runtime identifier (e.g. linux-x64, win-x86).
- --configfile _FILE_
- NuGet config file to use instead of the default chain.
- --disable-parallel
- Disable parallel downloads.
- -v, --verbosity _LEVEL_
- Verbosity: quiet, minimal, normal, detailed, diagnostic.
- -?, -h, --help
- Display help.
FAQ
What is the dotnet-restore command used for?
dotnet restore downloads and installs all NuGet package dependencies declared in a project, solution, or dotnet-tools.json. It reads PackageReference entries from .csproj/.fsproj/.vbproj files, queries the configured NuGet sources, and writes restored assets to obj/project.assets.json. Other commands like dotnet build and dotnet run trigger an implicit restore by default, so explicit invocation is mainly useful in CI pipelines (where you want to cache the restore step), when troubleshooting package resolution, or when --no-restore is being used downstream.
How do I run a basic dotnet-restore example?
Run `dotnet restore` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -s, --source _SOURCE_ do in dotnet-restore?
NuGet package source to use during restore (overrides nuget.config).