SlnMerge merges the solutions when creating solution file by Unity Editor.
- Unity 2018.4.5f1 + Windows 10 and macOS 10.15
- Microsoft Visual Studio 2019
- JetBrains Rider 2019.2
Clone this repository and copy those files.
If you are using Unity 2019.1 or later, you can use Package Manager to install a package via git.
https://github.com/Cysharp/SlnMerge.git?path=src
Create a setting XML file named <ProjectName>.sln.mergesettings
.
For example, when the project name is MyUnityApp
, Unity Editor generates MyUnityApp.sln
. You need to create MyUnityApp.sln.mergesettings
.
<SlnMergeSettings>
<MergeTargetSolution>..\MyUnityApp.Server.sln</MergeTargetSolution>
</SlnMergeSettings>
You can specify the target solution to merge by MergeTargetSolution
element.
NOTE: If you don't have the settings, SlnMerge uses ProjectName.Merge.sln
as a target.
The mergesettings file has the following settings:
Disabled
: Disable SlnMerge (default:false
)MergeTargetSolution
: Path of the solution you want to mergeNestedProjects
: Specify the projects to nest. Usually used as a solution folderNestedProject/FolderPath
: Folder path on solution (created if it doesn't exist; mutally exclusive with FolderGuid)NestedProject/FolderGuid
: GUID of folder on solution (mutally exclusive with FolderPath)NestedProject/ProjectName
: Project name (mutally exclusive with ProjectGuid)- Wildcard is available (
?
,*
)
- Wildcard is available (
NestedProject/ProjectGuid
: Project GUID (mutally exclusive with ProjectName)
ProjectConflictResolution
: Processing strategy when a solution contains a project with the same name (PreserveAll
,PreserveUnity
,PreserveOverlay
)PreserveAll
: Preserve all projects (both Unity generated projects and original projects)PreserveUnity
: Preserve Unity generated projects. (discard original project in a overlay solution)PreserveOverlay
: Preserve original projects in a overlay solution. (discard Unity generated projects from a merged solution)
You can use NestedProjects
settings to move projects to solution folders.
When a solution folder doesn't exist, SlnMerge will add the solution folder to the solution automatically. But, you need to define a solution folder as SolutionFolder
in mergesettings.
<SlnMergeSettings>
<MergeTargetSolution>..\ChatApp.Server.sln</MergeTargetSolution>
<SolutionFolders>
<!-- Define a solution folder named 'Unity' with GUID -->
<SolutionFolder FolderPath="Unity" Guid="{55739033-89BA-48AE-B482-843AFD452468}"/>
</SolutionFolders>
<NestedProjects>
<NestedProject ProjectName="Assembly-CSharp" FolderPath="Unity" />
<NestedProject ProjectName="Assembly-CSharp-Editor" FolderPath="Unity" />
</NestedProjects>
</SlnMergeSettings>
- Close Unity Editor.
- Delete .csproj and .sln are generated by Unity Editor.
- Reopen the project in Unity Editor
If a merge target solution has a project with the same name in the Unity generated solution, you can use use ProjectConflictResolution
option to fix the conflict in a 3-way.
- Preserve all projects (by default)
- Preserve the project in the merge target solution
- Preserve the project in the Unity generated solution
MIT License