Replies: 2 comments
-
As I mentioned in #3, the basic principles are map and data using active collections. However, even today it is still quite simple, for example: // provide some data; it can be either other processed .sln or from scratch, etc.
// for example, some headers ~
var header = new SlnHeader();
header.SetFormatVersion("12.0");
header.SetMinimumVersion("10.0.40219.1");
// some project collection from scratch ~
var projects = new[] { new ProjectItem("MyProject", ProjectType.Cs, "path") };
// ... and so on;
// then prepare write-handlers related to your data, eg.:
var whandlers = new Dictionary<Type, HandlerValue>()
{
[typeof(LVisualStudioVersion)] = new HandlerValue(new WVisualStudioVersion(header)),
[typeof(LProject)] = new HandlerValue(new WProject(projects, new LProjectDependencies())),
};
// commit this
using var w = new SlnWriter("result.sln", whandlers);
w.Write(new[] // for 2.5.x only manual mapping from scratch like here
{
new Section(new LVisualStudioVersion(), null),
new Section(new LProject(), null)
}); result.sln Microsoft Visual Studio Solution File, Format Version 12.00
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyProject", "path", "{CD128011-5F3E-4A88-A2D2-24A1E4DCD580}"
EndProject
|
Beta Was this translation helpful? Give feedback.
0 replies
-
2.7+// just a regular collections with your data
ConfigSln[] slnConf = [new("DBG", "x64")];
ProjectItem[] projects = [new ProjectItem(ProjectType.CsSdk, @"test\src.csproj", slnDir: baseDir)];
IConfPlatformPrj[] prjConfs = [new ConfigPrj("Debug", "x64", projects[0].pGuid, build: true, slnConf[0])];
// ...
LhDataHelper hdata = new();
hdata.SetHeader(SlnHeader.MakeDefault())
.SetProjects(projects)
.SetProjectConfigs(prjConfs)
.SetSolutionConfigs(slnConf);
//... everything else if you need to prepare
using SlnWriter w = new("result.sln", hdata);
await w.WriteAsync();
//string result = await await w.WriteAsStringAsync(); result.sln Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "test", "test\src.csproj", "{87B99093-788F-4223-B785-CB8961E196CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DBG|x64 = DBG|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{87B99093-788F-4223-B785-CB8961E196CA}.DBG|x64.ActiveCfg = Debug|x64
{87B99093-788F-4223-B785-CB8961E196CA}.DBG|x64.Build.0 = Debug|x64
EndGlobalSection
EndGlobal Use CreateProjectsIfNotExist if you need to create new projects together with .sln, using(SlnWriter w = new("result.sln", hdata))
{
w.Options = SlnWriterOptions.CreateProjectsIfNotExist; // <<<
await w.WriteAsync();
} I hope now creation of a solution from scratch can actually be done in a few steps. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The title is the question itself
Beta Was this translation helpful? Give feedback.
All reactions