Skip to main content
When you run dotnet new chromapperplugin -o MyPlugin, the template generates a ready-to-build Visual Studio project. This page explains every file in that project and how the template engine wires them together.

Directory layout

MyPlugin/
├── MyPlugin.csproj
├── packages.config
├── Plugin.cs
└── Properties/
    └── AssemblyInfo.cs

File reference

Plugin.cs

The entry point for your plugin. ChroMapper discovers the [Plugin] attribute on your class and calls the method marked [Init] when it loads the plugin.
using System.Reflection;
using UnityEngine;
using HarmonyLib;

namespace ChroMapperPluginTemplate;

[Plugin(Name)]
public class Plugin
{
    public const string Author = "YourName";
    public const string Name = "ChroMapperPluginTemplate";
    public const string ID = $"com.{Author}.{Name}";

    [Init]
    private void Init()
    {
        new Harmony(ID)
            .PatchAll(Assembly.GetExecutingAssembly());
        
        Debug.Log($"Hello from {Name}!");
    }
}
The three constants give you a single place to set your plugin’s identity:
ConstantPurpose
AuthorYour name or handle
NameDisplay name and assembly name
IDUnique reverse-DNS identifier used by Harmony

Properties/AssemblyInfo.cs

Standard .NET assembly metadata. After renaming, AssemblyTitle and AssemblyProduct both match your project name because the template engine replaces them automatically.
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("ChroMapperPluginTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChroMapperPluginTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("35E8370F-DC32-473E-9185-FF618F38C4C1")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Update AssemblyVersion and AssemblyFileVersion as you release new versions of your plugin.

MyPlugin.csproj

The MSBuild project file. Key settings:
PropertyValueMeaning
OutputTypeLibraryProduces a .dll, not an executable
TargetFrameworkVersionv4.8Matches the .NET version ChroMapper runs on
LangVersionlatestEnables the newest C# language features
See Build and deploy for the full post-build copy step defined in this file.

packages.config

Declares the single NuGet dependency:
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Krafs.Publicizer" version="2.3.0" targetFramework="net48" developmentDependency="true" />
</packages>
Krafs.Publicizer is a build-time-only tool (developmentDependency="true") that rewrites the ChroMapper assemblies in memory so that internal and private members appear public to your code. It does not ship in your output DLL.
The .template.config/template.json file exists in the template repository but is not copied into your generated project. It is consumed by dotnet new install to register the template and is not part of the generated output.

How sourceName renames your project

The sourceName field tells dotnet new to replace every occurrence of the string ChroMapperPluginTemplate in file names and file contents with whatever name you pass via -o or --name. For example, running:
dotnet new chromapperplugin -o MyAwesomePlugin
produces a project where:
  • The folder is named MyAwesomePlugin/
  • The project file is MyAwesomePlugin.csproj
  • RootNamespace and AssemblyName in the .csproj are MyAwesomePlugin
  • AssemblyTitle and AssemblyProduct in AssemblyInfo.cs are MyAwesomePlugin
  • The namespace in Plugin.cs is MyAwesomePlugin
  • The Name constant in Plugin.cs is "MyAwesomePlugin"

How the Author symbol works

The Author symbol replaces the literal string YourName in the generated files. Pass it on the command line with --Author:
dotnet new chromapperplugin -o MyAwesomePlugin --Author "alice"
This sets Plugin.Author to "alice" and therefore makes Plugin.ID equal to "com.alice.MyAwesomePlugin". If you omit --Author, the default value "YourName" is used and you can update it manually in Plugin.cs afterwards.

Build docs developers (and LLMs) love