Replies: 1 comment 1 reply
-
## 2.7+
```csharp
using Sln sln = new("input.sln", SlnItems.AllNoLoad);
SolutionFolder[] folders = [ new("My Folder"), ];
var projects = sln.Result.ProjectItems.ForEach(p =>
{
// all C# projects (legacy + Sdk-style) inside first folder^
if(p.IsCs()) { p.parent.Value = folders[0]; }
});
LhDataHelper hdata = new();
hdata.SetProjects(projects).SetFolders(folders);
using SlnWriter w = new("result.sln", hdata);
await w.WriteAsync(sln.Result.Map);
```
## 2.0+
```csharp
using Sln sln = new("input.sln", SlnItems.AllNoLoad);
List<SolutionFolder> folders = new() { new SolutionFolder("My Folder"), };
var projects = sln.Result.ProjectItems.ForEach(p =>
{
// all C# projects (legacy + Sdk-style) inside first folder^
if(p.IsCs()) { p.parent.Value = folders[0]; }
});
using SlnWriter w = new("result.sln", new Dictionary<Type, HandlerValue>()
{
[typeof(LProjectSolutionItems)] = new(new WProjectSolutionItems(folders)),
[typeof(LNestedProjects)] = new(new WNestedProjects(folders, projects)),
});
w.Write(sln.Result.Map);
```
Note, 2.6.x has a bug with a disappearing [`EndProject` line](993dcc9). Until [**2.7**](https://github.com/3F/MvsSln/releases/tag/2.7), keep configuring *LProject* handler if no changes like ~
```csharp
[typeof(LProject)] = new(new WProject(sln.Result.ProjectItems, sln.Result.ProjectDependencies)),
```
Prior to 2.7, you may also need to [prepare](#3 (comment)) your own skeleton for records that do not initially exist in the Map but are planned to be used.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kondr1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I can't found documentation. I try to load .csproj file and add it to the new solution folder. So… How to add new solution folder and write list of projects to this folder?
Beta Was this translation helpful? Give feedback.
All reactions