https://github.com/benmccallum/dotnet-references
A dotnet global tool for working with references in solution and project files
https://github.com/benmccallum/dotnet-references
csproj-tooling docker dotnet-core dotnet-global-tool github-actions
Last synced: 5 months ago
JSON representation
A dotnet global tool for working with references in solution and project files
- Host: GitHub
- URL: https://github.com/benmccallum/dotnet-references
- Owner: benmccallum
- License: mit
- Created: 2019-09-27T16:30:47.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-06T06:11:05.000Z (over 1 year ago)
- Last Synced: 2024-05-22T13:04:49.564Z (about 1 year ago)
- Topics: csproj-tooling, docker, dotnet-core, dotnet-global-tool, github-actions
- Language: C#
- Homepage:
- Size: 79.1 KB
- Stars: 15
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dotnet references

A [dotnet global tool](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools)
that aids with bulk solution and project file references changes and related directory
organisation.(Formerly `dotnet-fix-references`, see prior documentation for it [here](docs/README-dotnet-fix-references.md).)
# Installation
```dotnet tool install --global dotnet-references```
> Note: If using this in a scripted process you want to be consistent (like a build), you should pin to a specific version with `--version x.y.z`.
# Usage
```
Usage: dotnet-references [options]Arguments:
Mode The mode to run (fix or internalise)Options:
-ep|--entry-point The entry point to use (a .sln file or a directory)
-wd|--working-directory The working directory to use (under which all .sln and .csproj files are contained).
If not provided, defaults to directory of entry point.
-rupf|--remove-unreferenced-project-files Should unreferenced project files be removed?
(Caution! Deletes files! Only supported in fix mode).
-reig|--remove-empty-item-groups Should ItemGroup elements in project files that are empty be removed?
(Only supported in internalise mode).
-?|-h|--help Show help information
```Supports the following modes which have varying use cases.
## Mode 1: Fix
This mode can fix references between solution files and projects in one of two ways.> :warning: If the dotnet cli complains with "Specify which project file to use because this '...' contains more than one project file.", you've run into a limitation of the dotnet cli. A workaround is to execute from any random directory and utilise the `-ep` and `-wd` args. (eg. `mkdir temp && cd temp && dotnet references fix -ep ../ -wd .. -rupf` (or `-ep ../Company.Project.sln -wd ..`)).
### Directory-first
By passing a directory as the entry, the tool will assume that the current directory structure is the source of truth and will fix all project references inside all .sln and .csproj files to the correct relative path.> dotnet references fix -ep ./src
Use cases:
You have moved your source code into a new folder structure (via a script or otherwise) and don't want to manually updates all your project references in .sln and .csproj files. (Project file names must be the same).### File-first
By passing a .sln file, the tool will assume that it, and the path it references .csproj files, is the source of truth; thus moving the .csproj files into the correct directory structure.> dotnet references fix -ep Company.Project.sln
Use cases:
1. Overcoming Dockerfile COPY globbing limitations... See [here](docs/Dockerfile-use-case.md).## Mode 2: Internalise (PackageReference --> ProjectReference)
This mode "internalises" references, by turning package references to project references.
(The project name must be the same as the package name).> dotnet references internalise -wd ./src
Use cases:
1. You've consolidated separate projects (and packages) into a mono repo and want to swap all package references to local project references where possible.Note: It currently doesn't handle transitive dependencies (dependencies of dependencies), which you'll need to add manually.
# Word of warning
This tool updates/deletes files in-place. Backup anything you care about before running this tool.# Feature backlog
1. Support fix mode w/ .csproj entry