Slnx 2.0.1
Suggested Alternatives
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Slnx --version 2.0.1
NuGet\Install-Package Slnx -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Slnx" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Slnx" Version="2.0.1" />
<PackageReference Include="Slnx" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Slnx --version 2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Slnx, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Slnx&version=2.0.1
#tool nuget:?package=Slnx&version=2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Slnx
SLNX is a fast parser and writer for the (currently) new in-preview Visual Studio XML Solution format with a .slnx extension, introduced in Visual Studio 2022 17.10 Preview 3.
Reading
using Slnx;
var model = SlnxModel.Load(File.ReadAllText("TestSlnx.txt"));
foreach (Folder folder in model.TopLevelFolders!)
{
foreach (string file in folder.DescendantFiles!)
{
Console.WriteLine(file);
}
}
TestSlnx.txt content:
<Solution>
<Folder Name="Solution Items">
<File Path="File1.cs" />
<File Path=".editorconfig" />
<Project Path="File.csproj" />
<Folder Name="Test">
<File Path=".editorconfig" />
<File Path="data.cs" />
</Folder>
</Folder>
</Solution>
Output:
File1.cs
.editorconfig
Writing (for Slnx 2.0)
using Slnx;
using System.Text.Json;
// Note: This is a .NET 8 project and uses Collection Expressions.
var factory = new SlnxFactory();
var folder = new Folder("Solution Items");
folder.AddProjectWithPathOnly("./CSharp/CSharp.csproj");
folder.AddProjectWithPathOnly("./VB.NET/VB.NET.vbproj");
folder.AddProject(new Project("./DockerCompose/DockerCompose.dcproj", typeGuid: Guid.NewGuid(), config: new(solution: "*|*", project: "*|*|Deploy")));
var moreFolders = new Folder("C++");
moreFolders.AddFiles(["util.cpp", "util.h", "data.cc", "data.h"]);
folder.AddFiles(["File1.cs", "File2.cs"]);
factory.AddFolder(folder);
factory.AddProjectWithPathOnly("Slnx/Slnx.csproj");
factory.AddProjectWithPathOnly("App/App.shproj");
string content = factory.AsModel().Store();
File.AppendAllText("OutputSlnx.txt", content);
// To provide detailed information, I'll just JSONify it with System.Text.Json.
var model = SlnxModel.Load(File.ReadAllText("OutputSlnx.txt"));
Console.WriteLine(JsonSerializer.Serialize(model));
Writing (for Slnx 1.0)
using Slnx;
var factory = new SlnxFactory();
factory.Folders.Add(new Folder("Solution Items", new[]
{
new Project("./CSharp/CSharp.csproj"),
new Project("./VB.NET/VB.NET.vbproj"),
new Project("./DockerCompose/DockerCompose.dcproj", Guid.NewGuid(), new(solution: "*|*", project: "*|*|Deploy"))
}, new[]
{
new Folder("C++", Array.Empty<Project>(), Array.Empty<Folder>(), new[]
{
"util.cpp",
"util.h",
"data.cc",
"data.h"
})
}, new string[] { "File1.cs", "File2.cs" }));
factory.Projects.Add(new Project("Slnx/Slnx.csproj"));
factory.Projects.Add(new Project("App/App.shproj"));
var model = factory.AsModel();
model.Store("OutputSlnx.txt");
Both of these programs will generate OutputSlnx.txt
with the following contents:
<Solution>
<Project Path="Slnx/Slnx.csproj" />
<Project Path="App/App.shproj" />
<Folder Name="Solution Items">
<File Path="File1.cs" />
<File Path="File2.cs" />
<Project Path="./CSharp/CSharp.csproj" />
<Project Path="./VB.NET/VB.NET.vbproj" />
<Project Path="./DockerCompose/DockerCompose.dcproj" Type="a9ca3494-2d8e-43aa-a418-28709ddb90fc">
<Configuration Solution="*|*" Project="*|*|Deploy" />
</Project>
<Folder Name="C++">
<File Path="util.cpp" />
<File Path="util.h" />
<File Path="data.cc" />
<File Path="data.h" />
</Folder>
</Folder>
</Solution>
Compatibility
Slnx uses the .NET 6.0 Runtime, but it works fine for preceding versions, including .NET 7.0, 8.0, and future releases.
Product | Versions 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 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Changed configuration from Debug to Release. No changes to the library were made.