MvsSln 2.7.0

dotnet add package MvsSln --version 2.7.0
NuGet\Install-Package MvsSln -Version 2.7.0
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="MvsSln" Version="2.7.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MvsSln --version 2.7.0
#r "nuget: MvsSln, 2.7.0"
#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.
// Install MvsSln as a Cake Addin
#addin nuget:?package=MvsSln&version=2.7.0

// Install MvsSln as a Cake Tool
#tool nuget:?package=MvsSln&version=2.7.0

alternate text is missing from this package README image MvsSln

Customizable VisualStudio .sln parser with project support (.vcxproj, .csproj., …). Pluggable lightweight r/w handlers at runtime, and more … 🧩

Copyright (c) 2013-2024  Denis Kuzmin <> github/3F

「 ❤ 」 License

MvsSln contributors

MvsSln is waiting for your awesome contributions!


Releases Windows Linux
📦 NuGet status status
release Tests Tests


Build history


Why MvsSln

MvsSln provides the easiest way to complex work with Visual Studio .sln files and referenced projects (.vcxproj, .csproj., ...). Merge, Manage, Attach custom handlers and more. Because it's free, because it's open.

🌌 The most convenient work with projects, dependencies, their lazy loading, any folders, any items, references and much more in these different worlds;

💡 We are customizable and extensible library at runtime! Make your custom .sln and its parsing for everything you like at the moment you need just in a few steps;

🚀 We were born from other popular project to be more loyal for your preferences on the fly. Hello from 2013;

Even if you just need the basic access to information or more complex work through our readers and writers.

Create/modify/or just use parsed folders, projects, and other.

Safely compare anything,

if(new ProjectItem(...) == new ProjectItem(...)) { ... }
if(new SolutionFolder(...) == new SolutionFolder(...)) { ... }
if(new ConfigItem(...) == new ConfigItem(...)) { ... }
if(new PackageInfo(...) == new PackageInfo(...)) { ... }

Use 📂 Subdirectories,

new SolutionFolder("dir1", 
    new SolutionFolder("dir2", 
        new SolutionFolder("dir3", "hMSBuild.bat", "DllExport.bat")
new SolutionFolder("{EE7DD6B7-56F4-478D-8745-3D204D915473}", "MyFolder2", dir1, ".gnt\\gnt.core");

Projects and Folders,

new ProjectItem("Project1", ProjectType.Cs);
new ProjectItem("Project1", ProjectType.Cs, new SolutionFolder("dir1"));
new ProjectItem("Project2", ProjectType.Vc, "path 1");
new ProjectItem("{EE7DD6B7-56F4-478D-8745-3D204D915473}", "Project1", ProjectType.Cs, dir2);

Detect the real* project types,

* IsCs() - Checking both legacy `ProjectType.Cs` and modern `ProjectType.CsSdk` types.
. . .
* IsSdk() - While ProjectType cannot inform the actual use of the modern Sdk style in projects,
            current method will try to detect this by using the extended logic:

Load only what is needed at the moment,


using var sln = new Sln("Input.sln", SlnItems.Env);

    .LoadProjects(sln.Result.ProjectItemsConfigs.Where(p => p.project.IsCs()))
    .ForEach(xp =>
        xp.AddItem("Compile", @"financial\Invoice.cs");

Modify .sln at runtime,

// new collection from available projects but without project 'UnLib'
var projects = sln.Result.ProjectItems.Where(p => != "UnLib");

// prepare write-handlers
var whandlers = new Dictionary<Type, HandlerValue>() {
    [typeof(LProject)] = new HandlerValue(new WProject(projects, sln.Result.ProjectDependencies)),

// save result
using(var w = new SlnWriter(@"modified.sln", whandlers)) {

Manage packages.config,

// 2.6+
using Sln l = new("Input.sln", SlnItems.AllNoLoad | SlnItems.PackagesConfig);

IPackageInfo found = l.Result.PackagesConfigs
                                .SelectMany(s => s.Packages)
                                .FirstOrDefault(p => p.Id.StartsWith("Microsoft."));
// found.MetaTFM ...

Version v = l.Result.PackagesConfigs.First().GetPackage("LX4Cnh")?.VersionParsed;

Easily create files from scratch,

// 2.7+
LhDataHelper hdata = new();

using(SlnWriter w = new(solutionFile, hdata))
    w.Options = SlnWriterOptions.CreateProjectsIfNotExist;

using Sln sln = new(solutionFile, SlnItems.EnvWithMinimalProjects);
IXProject xp = sln.Result.Env.Projects.First();

xp.SetProperties(new Dictionary<string, string>()
    { "OutputType", "EXE" },
    { "TargetFramework", "net8.0" },
    { "Platforms", "x64" }

Everything at hand,

using(var sln = new Sln(@"D:\projects\Conari\Conari.sln", SlnItems.All & ~SlnItems.ProjectDependencies))
    //    sln.Result.ProjectDependencies.FirstBy(BuildType.Rebuild).pGuid,
    //    new ConfigItem("Debug", "Any CPU")

    var p = sln.Result.Env.GetOrLoadProject(
        sln.ProjectItems.FirstOrDefault(p => == name)

    var paths = sln.Result.ProjectItems
                            .Select(p => new { p.pGuid, p.fullPath })
                            .ToDictionary(p => p.pGuid, p => p.fullPath);

    // {[{27152FD4-7B94-4AF0-A7ED-BE7E7A196D57}, D:\projects\Conari\Conari\Conari.csproj]}
    // {[{0AEEC49E-07A5-4A55-9673-9346C3A7BC03}, D:\projects\Conari\ConariTest\ConariTest.csproj]}

    foreach(IXProject xp in sln.Result.Env.Projects)
        xp.AddReference(typeof(JsonConverter).Assembly, true);

        ProjectItem prj = ...

        xp.AddImport("../packages/DllExport.1.5.1/tools/net.r_eg.DllExport.targets", true);

        xp.SetProperty("JsonConverter", "30ad4fe6b2a6aeed", "'$(Configuration)' == 'Debug'");
                new PropertyItem("IsCrossTargetingBuild", "true"),
                new PropertyItem("CSharpTargetsPath", "$(MSBToolsLocal)\\CrossTargeting.targets")
        // ...

    sln.Result.ProjectConfigs.Where(c => c.Sln.Configuration == "Debug"); // project-cfgs by solution-cfgs
    // ...

} // release all loaded projects

And something more,


using var sln = new Sln("TestStruct.sln", SlnItems.Env);
sln.Result.Env.Projects.ForEach(xp => 
    xp.Project.Xml.PropertyGroups.Where(p => p.Condition.Contains("'$(Configuration)|$(Platform)'"))
    .Where(p =>
        sln.Result.ProjectItemsConfigs.All(s => 
    ).ForEach(p => p.Parent?.RemoveChild(p))

The any new solution handler (reader or writer) can be easily added because of our flexible architecture.

Control anything and have fun !

MvsSln was specially extracted and re-licensed from vsSolutionBuildEvent projects (GPL → MIT) for and others! Join us 🎈

High quality Project Icons. Visual Studio

Since Microsoft officially distributes 5,000 high quality free icons and bitmaps from products like Visual Studio,

You can also use related project icons together with MvsSln like it was already for .NET DllExport project:

alternate text is missing from this package README image

Follow License Terms for icons and Find implementation in original repo:

How or Where is used

Let's consider examples of use in real projects below.

.NET DllExport

DllExport project finally changed distribution of the packages starting with v1.6 release. The final manager now fully works via MvsSln:

alternate text is missing from this package README image

MvsSln also is a core logic in Post-Processing feature [?]

alternate text is missing from this package README image


vsSolutionBuildEvent now is completely integrated with MvsSln [?]

Fully removed original parser and replaced related processing from Environment/IsolatedEnv/MSBuild/CIM. Now it just contains lightweight invoking of relevant methods.

alternate text is missing from this package README image

alternate text is missing from this package README image

Map of .sln & Writers

v2+ now also may provide map of analyzed data. To enable this, define a bit 0x0080 for type of operations to parser.

Parser will expose map through list of ISection for each line. For example:

alternate text is missing from this package README image

  • Each section contains handler which processes this line + simple access via RawText if not.
  • All this may be overloaded by any custom handlers (readers - ISlnHandler) if it's required by your environment.

This map may be used for modification / define new .sln data through writers (IObjHandler). For example:

var data = new List<IConfPlatform>() {
    new ConfigSln("Debug", "Any CPU"),
    new ConfigSln("Release_net45", "x64"),
    new ConfigSln("Release", "Any CPU"),

var whandlers = new Dictionary<Type, HandlerValue>() {
    [typeof(LSolutionConfigurationPlatforms)] = new HandlerValue(new WSolutionConfigurationPlatforms(data)),

using(var w = new SlnWriter("<path_to>.sln", whandlers)) {

Projects. Adding References

XProject.AddPackageReference("Conari", "1.5.0");
xp.AddProjectReference(new ProjectItem(ProjectType.Cs, @$"{projName}\src.csproj"));
XProject.AddReference("DllExport", lib, AddReferenceOptions.MakeRelativePath);
    AddReferenceOptions.DefaultResolve | AddReferenceOptions.OmitVersion | AddReferenceOptions.HidePrivate
<Reference Include="MvsSln, PublicKeyToken=4bbd2ef743db151e" />
<Reference Include="DllExport, Version=, Culture=neutral, PublicKeyToken=8337224c9ad9e356">

Example of extending (your custom handlers)

Example of LProject handler (reader):

using static net.r_eg.MvsSln.Core.Keywords;

public class LProject: LAbstract, ISlnHandler
    public override ICollection<Type> CoHandlers { get; protected set; }
        = [typeof(LProjectDependencies)];

    public override bool IsActivated(ISvc svc)
        => (svc.Sln.ResultType & SlnItems.Projects) == SlnItems.Projects;

    public override bool Condition(RawText line)
        => line.trimmed.StartsWith(Project_, StringComparison.Ordinal);

    public override bool Positioned(ISvc svc, RawText line)
        ProjectItem pItem = GetProjectItem(line.trimmed, svc.Sln.SolutionDir);
        if(pItem.pGuid == null) return false;
        if(svc.Sln.ProjectItemList == null) svc.Sln.ProjectItemList = [];

        return true;

Example of WSolutionConfigurationPlatforms handler (writer):

using static net.r_eg.MvsSln.Core.Keywords;

public class WSolutionConfigurationPlatforms(IEnumerable<IConfPlatform> configs)
    : WAbstract, IObjHandler
    protected IEnumerable<IConfPlatform> configs = configs;

    public override string Extract(object data)
        if(configs == null) return null;


        configs.ForEach(cfg => lbuilder.AppendLv2Line($"{cfg} = {cfg}"));

        return lbuilder.AppendLv1(EndGlobalSection).ToString();

Download MvsSln

NuGet GetNuTool
package gnt MvsSln

Build MvsSln from source

git clone MvsSln
cd MvsSln

Windows. Visual Studio / MSBuild

build Release

or together with configured netfx4sdk

build-CI Release

Ubuntu 20.04

dotnet build -c Release

run unit tests

dotnet test -c Release --no-build --no-restore
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.0 was computed.  netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.7.0 120 4/29/2024
2.6.2 12,908 7/12/2023
2.6.1 39,761 1/31/2022
2.6.0 13,453 8/23/2021
2.5.3 31,752 7/23/2020
2.5.2 6,804 5/5/2020
2.5.1 33,840 1/30/2020
2.5.0 1,532 10/17/2019
2.4.0 1,366 8/10/2019
2.3.0 1,536 6/17/2019