BEFORE YOU BEGIN
Get the .NET SDK.
Kobo targets .NET 11. Install the .NET 11 SDK, then verify it is available from your terminal:
dotnet --list-sdksConfirm that an 11.0 SDK is listed. Kobo is in preview, so the install commands below use prerelease packages.
STANDALONE APP
Build your first program.
Install the command-line compiler as a global .NET tool. This is the recommended way to download Kobo and get started with a standalone project:
dotnet tool install --global thinkmine.kobo.lang --prereleaseCreate a file named hello.kobo:
import System
module Examples/Hello
[public] class:Program
{
[public, static] function:void Main(string[] args)
{
Console.WriteLine("Hello, world!")
}
}Compile it, then run the generated .NET assembly:
kobo build hello.kobo --output-directory ./build --name Hello
dotnet ./build/Hello.dllThe output includes Hello.dll and Hello.runtimeconfig.json. Keep both files to run the standalone app.
dotnet tool update --global thinkmine.kobo.lang --prerelease.EXISTING C# PROJECT
Bring Kobo into your build.
Use BuildTools when you want Kobo and C# files in the same SDK-style project. The package discovers .kobo files automatically; no separate compile step is needed.
dotnet add package thinkmine.kobo.lang.buildtools --prereleaseAdd Greeting.kobo to the project:
module Example/Greetings
[public] class:Greeting
{
[public] function:string For(string name)
{
return $"Hello, {name}, from Kobo!"
}
}Call the Kobo-defined type from your existing C# code as usual:
using Example.Greetings;
var greeting = new Greeting();
Console.WriteLine(greeting.For("Ada"));Now use dotnet build and dotnet run. Your project keeps control of dependencies, configuration, and the output assembly.
ONE FILE, ONE UTILITY
Keep a script self-contained.
The CLI can also compile a single Kobo file as a standalone app, without a project file. Add optional SDK, build-property, or NuGet package directives at the top:
#:sdk Microsoft.NET.Sdk
#:property Nullable=enable
import System
[public] class:Program
{
[public, static] function:void Main(string[] args)
{
var name = args.Length > 0 ? args[0] : "world"
Console.WriteLine($"Hello, {name}!")
}
}kobo build greet.kobo --output-directory ./build --name Greet
dotnet ./build/Greet.dll AdaAdd NuGet dependencies with #:package Package.Name@version. These directives apply to standalone single-file apps, not BuildTools or multi-file builds.
KEEP EXPLORING