---
title: "Install a desktop app template with dotnet new"
url: https://recursiveai.org/oneapp/cookbook/install-oneapp-dotnet-new-template/
description: "Install the OneApp template from NuGet, scaffold a C# desktop project with dotnet new oneapp, and run the generated window."
version: "1.1.1"
---

```shell
dotnet new install RecursiveAI.OneApp.Templates
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```shell
dotnet new oneapp -n MyApp
cd MyApp
dotnet run
```

The installer and scaffolder report these success messages (wrapped here):

```text
Success:
RecursiveAI.OneApp.Templates@1.1.1
installed the following templates:
The template "OneApp desktop app"
was created successfully.
```

The window starts with **Hello, World** and a counter at zero. Click the counter button once; its label changes to:

```text
Clicked 1 times
```

## Full program

Checked on Linux (X11) with OneApp 1.1.1. This recipe wasn’t run on Windows or macOS.

The download contains the starter app, with formatting adjusted to fit this page. `MyApp.csproj` targets `net10.0` and references `RecursiveAI.OneApp` and `RecursiveAI.OneApp.Kit` at 1.1.1. It includes the Native AOT publish setting and names `MyApp.Program.Main` as the Android entry.

```xml
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <InvariantGlobalization>true</InvariantGlobalization>
    <PublishAot>true</PublishAot>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <OneAppId>dev.example.myapp</OneAppId>
    <OneAppName>MyApp</OneAppName>
    <OneAppVersion>1.0.0</OneAppVersion>
    <OneAppIcon>icon.png</OneAppIcon>
    <OneAppAndroidMain>MyApp.Program.Main</OneAppAndroidMain>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference
      Include="RecursiveAI.OneApp"
      Version="1.1.1" />
    <PackageReference
      Include="RecursiveAI.OneApp.Kit"
      Version="1.1.1" />
  </ItemGroup>

</Project>
```

`MainPage.html` defines the window’s contents. The compiler turns the HTML, the accompanying `MainPage.css` stylesheet, and the partial C# class into a component.

```
<Theme>
  <main class="page">
    <Card>
      <CardHeader>
        <CardTitle>Hello, {Name}</CardTitle>
        <CardDescription>
          Edit MainPage.html and MainPage.cs
          to change this window.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <div class="field">
          <Label For="name">Your name</Label>
          <Input Id="name"
            Value="{Name}"
            OnValueChange="{v => Name = v}"
            Placeholder="World" />
        </div>
      </CardContent>
      <CardFooter>
        <Button Id="count"
          OnClick="{() => Clicks++}">
          Clicked {Clicks} times
        </Button>
      </CardFooter>
    </Card>
  </main>
</Theme>
```

`MainPage.css` starts with the page padding: 24 px, plus the part of the window a phone’s status bar, cut-out or gesture bar covers (0 on a desktop):

```css
.page {
  padding:
    calc(24px + var(--safe-area-inset-top, 0px))
    calc(24px + var(--safe-area-inset-right, 0px))
    calc(24px + var(--safe-area-inset-bottom, 0px))
    calc(24px + var(--safe-area-inset-left, 0px));
}
```

`MainPage.cs` supplies the state:

```csharp
using OneApp.Kit;
using OneUI.Components;

namespace MyApp;

public partial class MainPage
{
    [State]
    private partial string Name { get; set; }

    [State]
    private partial int Clicks { get; set; }

    /// <inheritdoc />
    protected override void OnMounted()
    {
        Name = "World";
    }
}
```

`Program.cs` mounts the page and starts the app. It is a class with `Main` rather than top-level statements, so the Android activity can call it:

```csharp
using OneApp;
using OnePlatform;

namespace MyApp;

public static class Program
{
    public static int Main(string[] args)
    {
        bool headless =
            args.Contains("--headless");

        var options = new AppOptions(
            new MainPage())
        {
            Title = "MyApp",
            AppId = "dev.example.myapp",
            Width = 480,
            Height = 360,
            Backend = headless
                ? PlatformBackendKind.Headless
                : PlatformBackendKind.Auto,
            UseGpu = !headless,
        };
        using var host = AppHost.Create(options);

        host.Run();
        return 0;
    }
}
```

![Generated OneApp window showing Hello, World and the counter after one click](https://recursiveai.org/oneapp/images/install-oneapp-dotnet-new-template/app.png)

If `dotnet new` can’t find `oneapp`, run `dotnet new list oneapp` to check whether the package installed, then verify that your configured NuGet sources include nuget.org.

## Variations

**Choose a different application ID.** Run this from the parent directory to scaffold a second project. Use a reverse-DNS name you control for your own app:

```shell
dotnet new oneapp -n NotesApp --appId dev.example.notes
```

## Related recipes

- [Build a desktop app with HTML and CSS in C#](https://recursiveai.org/oneapp/cookbook/build-desktop-app-with-html-css/)
- [Package a C# desktop app for Linux](https://recursiveai.org/oneapp/cookbook/package-dotnet-desktop-app-for-linux/)

## The short answer

Install `RecursiveAI.OneApp.Templates` with `dotnet new install`. Then run `dotnet new oneapp -n MyApp` to write a C# desktop app into `MyApp`. The package ID is what you install; `oneapp` is the short name you use to create projects from it.

## How do I install and list a custom dotnet new template?

Use `dotnet new install` for a template package, not `dotnet add package`. Installing the template makes it available to the CLI; it doesn’t add a runtime reference to a project. To check that the short name resolves and see which options the template supports, run:

```shell
dotnet new list oneapp
dotnet new oneapp --help
```

The [dotnet new install reference](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-new-install) explains how the CLI chooses a NuGet source and installs a specific template version. Installing or updating a template doesn’t rewrite existing projects. Those projects have their own package references in the `.csproj`.

## What files does the OneApp desktop app template generate?

Edit `MainPage.html` to change what’s on screen, `MainPage.css` to style it, and `MainPage.cs` for C# state. For example, the counter’s `OnClick` increments `Clicks`, and `{Clicks}` in the button label displays the new value. Edit `Program.cs` to change the title or the window size. The starter icon is `icon.png`, 512 px square; replace it before packaging your own app.

`-n` changes the project name and initial window title. `--appId` sets the app identity, which is separate from the visible title and is used for platform packaging. The scaffold also includes a local tool manifest for the optional `oneapp` CLI. From a project you scaffolded, run `dotnet tool restore` if you want that tool; you don’t need it to run the window. See the [template reference](https://recursiveai.org/oneapp/docs/templates/) for the other options.
