dotnet-slnmerge 0.5.0

dotnet tool install --global dotnet-slnmerge --version 0.5.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local dotnet-slnmerge --version 0.5.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dotnet-slnmerge&version=0.5.0
nuke :add-package dotnet-slnmerge --version 0.5.0

dotnet-slnmerge

Nuget Build

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

If you are using an older version of .NET, you may have to specify an older version of dotnet-slnmerge:

dotnet tool install --global dotnet-slnmerge --version 0.4.0
SDK Version Last Package Version
2.1 0.1.2
3.1 0.4.0
5.0 0.4.0

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 Compatible and additional computed target framework versions.
.NET 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.5.0 352 12/19/2023
0.4.0 654 11/10/2022
0.3.0 488 11/8/2021
0.2.2 367 8/23/2021
0.2.1 441 5/17/2021
0.2.0 486 5/16/2021
0.1.2 414 4/27/2021
0.1.1 333 2/20/2021
0.1.0 356 1/29/2021