Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install nuget package in ASP.NET Core project by the CLI

I'd like to add Microsoft.AspNetCore.StaticFiles to ASP.NET Core project.

Is there another way rather than editing manually the .csproj file? If I do nuget install it installs it in the current project folder and no change is applied to the .csproj file.

The OS is *nix one so I'm using VSCode and a terminal/console.

like image 383
Petar Ivanov Avatar asked Mar 03 '17 22:03

Petar Ivanov


People also ask

Which command is used to install NuGet packages using dotnet CLI?

NuGet installs the latest version of the package when you use the dotnet add package command unless you specify the package version ( -v switch).


1 Answers

The .NET Core SDK which has support for the new Sdk style .csproj files allows you to do this from the command line if you are using a .csproj file.

dotnet add <PROJECT> package [arguments] [options]
dotnet add package Microsoft.AspNetCore.StaticFiles
dotnet add package Microsoft.AspNetCore.StaticFiles -v 1.0.1

If you are using project.json files then there is no command line support for that as far as I am aware.

like image 148
Matt Ward Avatar answered Sep 18 '22 01:09

Matt Ward