# Your first plugin

> Generate, pack, and run a plugin.

import { Tabs, TabItem } from "@astrojs/starlight/components";

This walks a working server to a running plugin. It assumes the framework is already installed on the server; if it is not, do [Server](/framework/server/) first.

You need the [.NET 10 SDK](https://dotnet.microsoft.com/download) on your machine to build the plugin. The server needs the .NET 10 runtime, which it already has if the framework starts.

## Generate

From a directory outside the server:

```bash
dotnet new install Hosihikari.Plugin.Templates
dotnet new hosihikari-plugin -n HelloPlugin -o HelloPlugin
```

The result is a complete precompiled plugin project. Choose the F# template with `dotnet new hosihikari-plugin-fsharp` instead.

The published template is still version 1.1.0: its project pins the 1.x contract (`[1.2.0]`), its hooks are the synchronous 1.x signatures, and its own build target writes the old `manifest.json`-only envelope. Bring it onto the current line before packing — upgrade the contract, replace the hook signatures with the async ones from [Migrate from 1.x to 2.0](/framework/migrate/v2/#2-make-the-hooks-async), and pack with the 2.0 build package:

```bash
dotnet add ./HelloPlugin/HelloPlugin.csproj package Hosihikari.Plugin.Abstractions --version 2.0.1
dotnet add ./HelloPlugin/HelloPlugin.csproj package Hosihikari.Plugin.Build --version 1.2.0
```

Upgrading the contract alone does not compile — the compiler demands the new hook signatures, which is exactly the rewrite the migration page walks through.

## Pack

```bash
dotnet build ./HelloPlugin/HelloPlugin.csproj -t:PackPlugin
```

`PackPlugin` produces `HelloPlugin/dist/HelloPlugin/` — the package directory, with `hosihikari.json` and the generated `manifest.json` already filled in. A multi-target project needs `-f <tfm>`.

## Install on the server

Set `Server` to the server root once:

<Tabs syncKey="shell">
  <TabItem label="bash">
    ```bash
    Server=/path/to/bedrock-server
    ```
  </TabItem>
  <TabItem label="PowerShell 7">
    ```pwsh
    $Server = 'C:\bedrock-server'
    ```
  </TabItem>
</Tabs>

Copy the directory into the server:

```bash
cp -r ./HelloPlugin/dist/HelloPlugin "$Server/plugins/HelloPlugin"
```

The directory name must equal `name` in `hosihikari.json`. Restart the server.

## Verify

The log should show the plugin loading and enabling. Then check what it wrote:

```bash
ls "$Server/data/hosihikari/HelloPlugin"
```

A data directory with the plugin's files means it ran.

## What to read next

- [Plugin packages](/framework/develop/plugin-package/) — the manifest, the checks before load, the lifecycle.
- [Templates](/framework/develop/templates/) — the two templates and what they generate.
- [C# plugins](/framework/develop/authoring-csharp/) or [F# plugins](/framework/develop/authoring-fsharp/) — writing the plugin body.
- [Troubleshooting](/framework/develop/troubleshooting/) when the plugin does not appear in the log.

## Writing source instead

The templates produce a precompiled assembly. To ship `.cs` or `.fsx` source that the server compiles at load, install the matching loader package and point `entry` at the source file. See [C# plugins](/framework/develop/authoring-csharp/) for the layout.
