dotnet-slnmerge 0.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global dotnet-slnmerge --version 0.3.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.3.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dotnet-slnmerge&version=0.3.0
nuke :add-package dotnet-slnmerge --version 0.3.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

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 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 was computed.  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. 
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 366 12/19/2023
0.4.0 655 11/10/2022
0.3.0 489 11/8/2021
0.2.2 368 8/23/2021
0.2.1 442 5/17/2021
0.2.0 486 5/16/2021
0.1.2 415 4/27/2021
0.1.1 334 2/20/2021
0.1.0 357 1/29/2021