The CLI needs to provide a way for users to add project and package references to the project file.
Below is a mini-spec of the command.
Note: this is a mini-spec, more detailed documents will be available on docs.microsoft.com
dotnet <operation> <project_or_solution> <command> <project_or_package> <args>
addlistremoveupdate projectpackageArguments are here mostly for the package command. Arguments are the following:
--version | -v - provides a version for the package to be added. If none is specified, latest is assumed.--pre-release | -p - specify whether to check for pre-release packages as well. --frameworks | -f - place the package reference under the specified framework. --no-restore | -n - do not restore after the operation completes. <ProjectReference> to the project in question. dotnet add project "../path/to/project.csproj"dotnet add package package.id --version 1.0.0dotnet list path/to/project.csproj packageIt would be awesome to also have a sub-verb to update NuGet references / show if an update is available.
Honestly, I don't see a need for a specialized command just to add a <PackageReference> tag to the csproj; I do it by hand and have no problems. On the other hand, @dasMulli's suggestion about a command to update NuGet references is a _great_ idea.
@wjk It is a very useful feature of NodeJS to be able to install/uninstall a package from the command line for certain build systems. I would imagine it would be equally useful in dotnet.
this command will not put TFM-specific dependencies in the project file. For that, a manual edit will have to be done
I think if it did support TFM-specific references, this would be highly useful since adding a PackageReference is easy, but getting the condition right from memory not so much (srsly, "do i need to wrap things with apostrophes? do i need brackets for the $xyz expressions? what was that variable called again anyway?")
For adding references, a switch could be added for the target framework:
--framework | -fUse cases:
dotnet ref add Microsoft.AspNetCore.Hosting.WindowsServices -f net462dotnet ref add Microsoft.NETCore.App -v 1.1.0 -f netcoreapp1.1Logic could be (design needed):
If VS "15", NuGet 4.* VSIX already has logic for that, it could be "borrowed".
(Same applies to projects / ProjectReference)
Tracking issue is dotnet/cli#4746
It's possible to add also an option to set also PrivateAssets property for PackageReference?
it's useful for adding sdk packages who need <PrivateAssets>All</PrivateAssets>
So something like --private-assets "All" ?
@blackdwarf if ok, i can add that (i need that for adding fsharp sdk package :D, so personal interests) but i think is useful for scripting/tutorial to add dotnet test sdk packages
So like
dotnet new@enricosada I like the proposal. Can you wait on dotnet/cli#4758? We decided to change the calling convention for this class of commands to get back to dotnet {verb} {subject} {object} behavior and @krwq is making fairly big code changes to account for that. Once it's merged, we'll have a basis for other commands including adding package refs and the private flag.
@rrelyea I believe this ask, having a verb to add a nuget package reference and marking it
@dasMulli Can you open an issue in nuget/home to track the PackageRef update verb you propose?
@blackdwarf can you update the docs at the top to match the current POR for impl?
Honestly, I don't see a need for a specialized command just to add a
tag to the csproj; I do it by hand and have no problems
the command is for cli, but is also useful because you can automate things (from ide/tools or script).
dotnet add p2p dotnet remove p2p and dotnet list p2ps are already here. Dlls are out of scope. Packages are done by NuGet team.
@piotrpMSFT, can we close this? We already have https://github.com/dotnet/cli/issues/4746
Yea, dotnet add p2p is done.
@enricosada make sure the add ref features you're asking for get logged in nuget/home.