Install NuGet Packages with Command Line Interface (CLI) Tools
- 4 minutes to read
Note
Nu
You can use console tools - .NET CLI and NuGet CLI - to manage project dependencies. Sections below demonstrate how you can add or remove NuGet packages and execute miscellaneous operations.
#.NET CLI: Add DevExpress NuGet Packages to a Project
You can use a feed authorization key or NuGet feed URL to add NuGet packages to your project. For more information on these approaches, refer to the sections below.
#Use Feed Authorization Key
The first approach uses the following information for authorization:
- Username: use the -u option and specify
DevExpress
as the option value. - Password: obtain your feed authorization key and use it as the -p option’s value.
Use the command below to add DevExpress as a NuGet package source:
# Add DevExpress as a package source
dotnet nuget add source https://nuget.devexpress.com/api/v3/index.json -n DXFeed -u DevExpress -p {your-feed-authorization-key}
# Add packages to your project
dotnet add {ProjectName}.csproj package DevExtreme.AspNet.Core -v 21.1.5
Non-Windows operating systems do not support password encryption. To store credentials as plain text on these systems, add the --store-password-in-clear-text
option to the command:
# Add DevExpress as a package source
dotnet nuget add source https://nuget.devexpress.com/api/v3/index.json -n DXFeed -u DevExpress -p {your-feed-authorization-key} --store-password-in-clear-text
Note
Storing passwords in clear text is strongly discouraged. For more information on managing credentials securely, refer to the following Microsoft topic: Consuming packages from authenticated feeds - Security best practices for managing credentials.
#Use NuGet Feed URL
This approach uses a NuGet feed URL that specifies a package source for installed NuGet packages.
# Add DevExtreme.AspNet.Core to the current project
# Use the -s key to specify the package source
dotnet add package DevExtreme.AspNet.Core -s https://nuget.devexpress.com/{your-feed-authorization-key}/api/v3/index.json -s https://api.nuget.org/v3/index.json
Note
Storing passwords in clear text is strongly discouraged. For more information on managing credentials securely, refer to the following Microsoft topic: Consuming packages from authenticated feeds - Security best practices for managing credentials.
#.NET CLI: Miscellaneous Commands
Once installed, you can manage DevExpress packages like other NuGet packages, for example, remove them.
# Remove the DevExtreme.AspNet.Core package
dotnet remove package DevExtreme.AspNet.Core
# Automatically install all the dependencies in the project file
dotnet restore
Refer to Microsoft documentation for more information on how to use the .NET CLI to manage packages: .NET CLI.
#NuGet CLI: Add DevExpress NuGet Packages to a Project
You can use a feed authorization key or NuGet feed URL to add NuGet packages to your project. For more information on these approaches, refer to the sections below.
#Use Feed Authorization Key
The following command installs a package into the current project. Specify the credentials to complete the installation:
- Username:
DevExpress
- Password: specify your feed authorization key
> nuget install DevExtreme.AspNet.Core -Source https://nuget.devexpress.com/api/v3/index.json -Source https://api.nuget.org/v3/index.json
Feeds used:
https://nuget.devexpress.com/api/v3/index.json
https://api.nuget.org/v3/index.json
Please provide credentials for: https://nuget.devexpress.com/api/v3/index.json
UserName: DevExpress
Password: {your-feed-authorization-key}
Note
Storing passwords in clear text is strongly discouraged. For more information on managing credentials securely, refer to the following Microsoft topic: Consuming packages from authenticated feeds - Security best practices for managing credentials.
#Use NuGet Feed URL
This approach uses a NuGet feed URL to specify the package source for installed NuGet packages.
# Add DevExtreme.AspNet.Core to the current project
nuget install DevExtreme.AspNet.Core -Source https://nuget.devexpress.com/{Your feed authorization key}/api/v3/index.json -Source https://api.nuget.org/v3/index.json
#NuGet CLI: Miscellaneous Commands
The sample below illustrates different console inputs that allow you to manage NuGet packages.
# Update all packages in the project
# You can omit the `{your-feed-authorization-key}` URL part, if you have your credentials saved in Windows Credentials
# **Control Panel** → **User Accounts** → **Credential Manager** → **Windows Credentials**
nuget update -Source https://nuget.devexpress.com/{Your feed authorization key}/api/v3/index.json -Source https://api.nuget.org/v3/index.json
# Update the DevExtreme.AspNet.Core package
nuget update -Id DevExtreme.AspNet.Core -Source https://nuget.devexpress.com/{Your feed authorization key}/api/v3/index.json -Source https://api.nuget.org/v3/index.json
# Remove the DevExtreme.AspNet.Core package
nuget delete DevExtreme.AspNet.Core
# Install missing packages
dotnet restore -s https://nuget.devexpress.com/{Your feed authorization key}/api/v3/index.json -s https://api.nuget.org/v3/index.json
Refer to Microsoft documentation for more information on NuGet CLI and its commands: NuGet CLI Reference.