Add a dotnet-ref command to enable adding references to the project file
See original GitHub issueThe 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
Usage
dotnet <operation> <project_or_solution> <command> <project_or_package>
<args>
Operations
add
list
remove
update
Commands
project
package
Arguments
- <operation>
- One of the operation from the previous list
- <command>
- One of the commands from the above list
- <project_or_solution>
- A project or a solution path
- <project_or_package>
- Path to the project file to include in the project or a package ID for package references
- <args>
- Arguments to the command
Defaults
- If the <project> is not present, we will try to see if there is a project in the current directory; if there is, it will be added, if not, an error is displayed
- If the <project_or_solution> is not present, we will check the current directory for either a project file or a sln file.
- If neither are found, an error is displayed
- If more than one is found or if there is both sln and a project file present, an error is displayed prompting the user to specify which file the operation should work on.
Arguments
Arguments 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.
Notes
- This command adds a project to a solution if it works on an SLN file. In case a project file, it will add a
<ProjectReference>
to the project in question. - The command will make absolute paths of the project being added relative to the solution file/project being added. This is done to avoid messy breaks when moving machines.
Examples
dotnet add project "../path/to/project.csproj"
- Add a project found at the specified path to the project file
- `dotnet remove package Newtonsoft.json
- Remove a package with the specified ID
dotnet add package package.id --version 1.0.0
- Add the package with package ID of “package.id” with the specified version.
dotnet list path/to/project.csproj package
- List out all of the packages in the specified project file
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:12 (9 by maintainers)
Top Results From Across the Web
dotnet add reference command - .NET CLI
The dotnet add reference command provides a convenient option to add project-to-project references.
Read more >Add a dotnet-ref command to enable adding references ...
This command adds a project to a solution if it works on an SLN file. In case a project file, it will add...
Read more >1.5: Adding Other Projects and References - DotNet-302- ...
Add Project References. Navigate into your EFConnect.API project in your command line. dotnet add reference ../EFConnect.Data/EFConnect.Data.csproj.
Read more >Manage Project and Package References with .net CLI
The dotnet add package provides a convenient option to add a package reference to a project file. After running the command, a compatibility ......
Read more >How to add a .dll reference to a project in Visual Studio
I see 1) A top menu "Project --> Add Reference..." 2) on side of screen, Solution Explorer, myProjectName, References. I can right click...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the command is for cli, but is also useful because you can automate things (from ide/tools or script).
It’s possible to add also an option to set also
PrivateAssets
property forPackageReference
? 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 😄, so personal interests) but i think is useful for scripting/tutorial to adddotnet test
sdk packages So likedotnet new