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 * from System
module Examples/Hello
[public] class:Program
{
[public, static] function:void Main(string[] args)
{
Print("Hello, world!")
}
}Compile it, then run the generated .NET assembly:
kobo build --source 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.PROJECT-BASED KOBO
Bring Kobo into your build.
Use BuildTools when Kobo files belong to an SDK-style .NET project. The package discovers .kobo files automatically; no separate Kobo assembly is needed for each file.
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!"
}
}Use the public type from another Kobo file in the project:
import * from Example/Greetings
[public] class:Program
{
[public, static] function:void Main(string[] args)
{
var greeting = new Greeting()
Print(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 * from System
[public] class:Program
{
[public, static] function:void Main(string[] args)
{
var name = args.Length > 0 ? args[0] : "world"
Print("Hello, ${name}!")
}
}kobo build --source 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