dotnet-slnmerge
0.4.0
See the version list below for details.
dotnet tool install --global dotnet-slnmerge --version 0.4.0
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local dotnet-slnmerge --version 0.4.0
#tool dotnet:?package=dotnet-slnmerge&version=0.4.0
nuke :add-package dotnet-slnmerge --version 0.4.0
dotnet-slnmerge
A .NET CLI tool to automatically merge projects in multiple solutions, adding <ProjectReference>
s when a corresponding <PackageReference>
is found.
Usage
Install the tool globally with:
dotnet tool install --global dotnet-slnmerge
Merge projects from one or more solutions into another:
slnmerge src/ ../other/solution.sln
Undo the merge operation with:
slnmerge -u src/ ../other/solution.sln
Why?
I find myself having to debug changes in different projects across multiple solutions at once that normally use <PackageReference>
s. Adding these as <ProjectReference>
s and adding to the solution simplifies debugging. For large projects with multiple repositories, this can be a very tedious task to set up by hand.
Example
Take the 3 solutions in separate repositories checked out locally:
/repos/
|- Server/
| \- Server.sln
| \- src/Server/Server.csproj
| Package References
| \- Data
|- Data/
| \- Data.sln
| \- src/Data/Data.csproj
| Package References
| \- Core
\- Core/
\- Core.sln
\- src/Core/Core.csproj
Run:
PS /repos> slnmerge Server Data Core
Tip: You can specify a solution file or a folder containing one.
The structure afterwards:
/repos/
|- Server/
| \- Server.sln
| |- src/Server/Server.csproj
| | Package References
| | \- Data
| | Project References
| | \- ../../../Data/src/Data/Data.csproj
| |- ../Data/src/Data/Data.csproj
| | Package References
| | \- Core
| | Project References
| | \- ../../../Core/src/Core/Core.csproj
| \- ../Core/src/Core/Core.csproj
|
|- Data/
| \- Data.sln
| |- src/Data/Data.csproj
| | Package References
| | \- Core
| | Project References
| | \- ../../../Core/src/Core/Core.csproj
| \- src/Core/Core.csproj
\- Core/
\- Core.sln
\- src/Core/Core.csproj
The result of slnmerge are projects that have a ProjectReference added for every local project that it finds that corresponds to a PackageReference. Solutions are also updated to include those newly reference projects.
If you open Server.sln in an IDE, you can modify sources and set breakpoints in Core and debug Server with those changes.
If you wish to remove the references added by this tool without reverting all changes in .csproj and .sln files:
PS /repos> slnmerge --undo Server Data
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
This package has no dependencies.