Linux command
dotnet-add-reference 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Add project reference
dotnet add reference [../Other/Other.csproj]
Add multiple references
dotnet add reference [../Lib1/Lib1.csproj] [../Lib2/Lib2.csproj]
Add reference to specific project
dotnet add [src/App/App.csproj] reference [../Lib/Lib.csproj]
说明
dotnet add reference adds project-to-project (P2P) references to a project file, creating build-time dependencies between projects in a solution. Referenced projects are automatically built before the referencing project, ensuring correct build order. P2P references enable code sharing within a solution while maintaining clear dependency boundaries. The command modifies the `.csproj` (or `.fsproj`, `.vbproj`) file to add `<ProjectReference>` elements with relative paths to the referenced projects.
参数
- -f, --framework _framework_
- Add reference only for specific target framework.
- --interactive
- Allow the command to prompt for input.
FAQ
What is the dotnet-add-reference command used for?
dotnet add reference adds project-to-project (P2P) references to a project file, creating build-time dependencies between projects in a solution. Referenced projects are automatically built before the referencing project, ensuring correct build order. P2P references enable code sharing within a solution while maintaining clear dependency boundaries. The command modifies the `.csproj` (or `.fsproj`, `.vbproj`) file to add `<ProjectReference>` elements with relative paths to the referenced projects.
How do I run a basic dotnet-add-reference example?
Run `dotnet add reference [../Other/Other.csproj]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f, --framework _framework_ do in dotnet-add-reference?
Add reference only for specific target framework.