KeyValues2 0.10.0

dotnet add package KeyValues2 --version 0.10.0
                    
NuGet\Install-Package KeyValues2 -Version 0.10.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="KeyValues2" Version="0.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KeyValues2" Version="0.10.0" />
                    
Directory.Packages.props
<PackageReference Include="KeyValues2" />
                    
Project file
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 KeyValues2 --version 0.10.0
                    
#r "nuget: KeyValues2, 0.10.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.
#:package KeyValues2@0.10.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KeyValues2&version=0.10.0
                    
Install as a Cake Addin
#tool nuget:?package=KeyValues2&version=0.10.0
                    
Install as a Cake Tool

Datamodel.NET is a library which implements the Datamodel structure and Datamodel Exchange (DMX) file format.

Datamodel is a strongly-typed generic data structure designed by Valve Corporation. It is primarily used as a developer storage format for meshes, animations, and maps.

Usage

dotnet add package KeyValues2
using Datamodel;

// Load a file with unknown layout
using var dm = Datamodel.Load("my_file.dmx");
var element = dm.Root;
var value = element.Get<string>("my_property");

// Load a file with a known layout
using var map = Datamodel.Load<CMapRootElement>("fy_pool.vmap");
var root = (CMapRootElement)map.Root;
Debug.Assert(root.IsPrefab == false);

// Layout definition
// Full implementation can be found here:
// https://github.com/ValveResourceFormat/Datamodel.NET/blob/master/Tests/ValveMap.cs
[LowercaseProperties]
class CMapRootElement : Element
{
    public bool IsPrefab { get; set; }
    public int EditorBuild { get; set; } = 8600;
    public int EditorVersion { get; set; } = 400;
}

Features

  • Support for all known versions of Valve's binary and keyvalues2 DMX encodings
  • Inline documentation
  • Binary codec supports just-in-time attribute loading
  • Write your own codecs with the ICodec interface
  • Serialize and deserialize support for Datamodel.Element subclasses

Serialization

var HelloWorld = new Datamodel.Datamodel("helloworld", 1); // must provide a format name (can be anything) and version

HelloWorld.Root = new Datamodel.Element(HelloWorld, "my_root");
HelloWorld.Root["Hello"] = "World"; // any supported attribute type can be assigned

var MyString = HelloWorld.Root.Get<string>("Hello");

HelloWorld.Save("hello world.dmx", "keyvalues2", 1); // must provide an encoding name and version
<--! dmx encoding keyvalues2 1 format helloworld 1>
{
    "Hello" "string" "World"
}

Attributes

The following .NET types are supported as Datamodel attributes:

  • int
  • float
  • bool
  • string
  • byte
  • byte[]
  • Vector2
  • Vector3
  • Vector4 / Quaternion
  • Matrix4x4
  • ulong
  • System.TimeSpan

Additionally, the following Datamodel.NET types are supported:

  • Element (a named collection of attributes)
  • QAngle

IList<T> collections of the above types are also supported. (This can be a bit confusing given that both byte and byte[] are valid attribute types; use the ByteArray type if you run into trouble.)

License

Datamodel.NET is licensed under the MIT License.

The sample .dmx and .vmap files under Tests/Resources are derived from Valve Corporation game content and are included solely as test fixtures. They are not covered by the MIT license above and remain the property of Valve Corporation. They are not distributed in the NuGet package.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on KeyValues2:

Package Downloads
ValveResourceFormat

Parser, decompiler, and exporter for Valve's Source 2 resource file formats. Supports models, textures, materials, maps, particles, and more.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on KeyValues2:

Repository Stars
ValveResourceFormat/ValveResourceFormat
Source 2 Viewer is an all-in-one tool to browse VPK archives, view, extract, and decompile Source 2 assets, including maps, models, materials, textures, sounds, and more.
Version Downloads Last Updated
0.10.0 0 8/24/2026
0.9.0 38 8/22/2026
0.9.0-beta 255 6/5/2025
0.8.0 25,919 5/25/2025
0.7.0 227 5/24/2025
0.5.0 4,563 9/25/2024
0.5.0-beta 6,631 3/11/2024
0.4.0 1,184 1/22/2024
0.3.0 6,921 6/30/2023
0.2.0 372 5/3/2023