CS2API 1.0.5

dotnet add package CS2API --version 1.0.5
                    
NuGet\Install-Package CS2API -Version 1.0.5
                    
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="CS2API" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CS2API" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="CS2API" />
                    
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 CS2API --version 1.0.5
                    
#r "nuget: CS2API, 1.0.5"
                    
#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 CS2API@1.0.5
                    
#: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=CS2API&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=CS2API&version=1.0.5
                    
Install as a Cake Tool

CS2API

A C# wrapper and transpiler for Counter-Strike 2's Workshop JavaScript API. Write your point_script scripts in C# with full type safety and IntelliSense, then automatically transpile them to clean JS.

Why?

CS2 Workshop scripts are written in JavaScript using the point_script entity API. CS2API lets you write those scripts in C# instead, giving you:

  • Type safety -- catch errors at compile time, not in-game
  • IntelliSense -- full autocomplete for every API method, event, and type
  • Clean output -- transpiles to dependency-free JS that runs directly in CS2's V8 environment

Installation

dotnet add package CS2API

The package includes both the API stubs (for writing scripts) and the compiler (for transpiling to JS). After building your project, the transpiler runs automatically and outputs .js files to a Scripts/ directory.

Quick Start

Create a new console or class library project and add the CS2API package. Then write a script:

using CS2API;

namespace MyWorkshopMap;

public class Script
{
    public static void Main()
    {
        Instance.Msg("Hello from C#!");

        Instance.OnRoundStart(() =>
        {
            Instance.Msg("Round started!");
        });

        Instance.OnPlayerChat((e) =>
        {
            Instance.Msg($"Player said: {e.text}");
        });
    }
}

This transpiles to:

import { Instance } from "cs_script/point_script";
Instance.Msg("Hello from C#!");
Instance.OnRoundStart(() => {
  Instance.Msg("Round started!");
});
Instance.OnPlayerChat((e) => {
  Instance.Msg(`Player said: ${e.text}`);
});

Configuration

By default, the transpiler runs after every build and outputs to Scripts/. You can customize this in your .csproj:

<PropertyGroup>
  
  <CS2APIOutputDir>$(MSBuildProjectDirectory)\MyScripts</CS2APIOutputDir>

  
  <CS2APICompilerEnabled>false</CS2APICompilerEnabled>
</PropertyGroup>

Type Mappings

C# JS
Instance.Msg(text) Instance.Msg(text)
new Vector(1, 2, 3) { x: 1, y: 2, z: 3 }
new Color(255, 0, 0) { r: 255, g: 0, b: 0 }
$"Hello {name}" `Hello ${name}`
player?.GetPawn() player?.GetPawn()
(int)expr expr
Math.Floor(x) Math.floor(x)

Project Structure

Your C# scripts should follow this pattern:

  • Namespace -- used for organization, stripped in output
  • Script class -- the wrapper class, unwrapped in output
  • Main() method -- the entry point, its body becomes top-level statements
  • Other methods -- transpiled to JS function declarations

License

See LICENSE.md for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.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.

Version Downloads Last Updated
1.0.5 31 3/21/2026
1.0.4 35 3/21/2026
1.0.3 26 3/21/2026
1.0.2 31 3/21/2026
1.0.1 26 3/20/2026
1.0.0 33 3/20/2026