Creating a Multi-targeted Rhino Plug-In Package

The Package Manager was introduced in Rhino 7. It makes it easier to discover, install and manage Rhino plug-ins from within Rhino. This guide will describe how to create a package from a Rhino plug-in that can be published to the package server.

Note
The package manager is cross-platform. The examples below are for Windows. For Mac, replace the path to the Yak CLI tool with "/Applications/Rhino 8.app/Contents/Resources/bin/yak".

First, let’s assume you have a build directory on your computer which contains all the files that you would like to distribute in your multi-targeted package. Something like below.

C:\Users\Bozo\dist\
├───net48                            
│   │   icon.png                     
│   │   Tamarin.rhp                  
│   └───misc                         
│           License.txt              
│           README.md                
└───net7.0                           
    │   icon.png                     
    │   Tamarin.rhp                  
    └───misc                         
            License.txt              
            README.md                
Note
This is just an example. The only files that matter are Tamarin.rhp and icon.png (we’ll reference the icon in the manifest.yml file later).

We’re going to use the Yak CLI tool to create the package, so open up a Command Prompt and navigate to the directory above.

cd C:\Users\Bozo\dist\

Now, we need a manifest.yml file! You can easily create your own by studying the Manifest Reference Guide. Alternatively, you can use the spec command to generate a skeleton file. We’ll do the latter here.

> "C:\Program Files\Rhino 8\System\Yak.exe" spec

Inspecting content: Tamarin.rhp

---
name: tamarin
version: 1.0.0
authors:
- Park Ranger
description: An example RhinoCommon plug-in
url: https://example.com


Saved to C:\Users\Bozo\dist\manifest.yml

The spec command takes a look at the current directory and, if present, will glean useful information from the .rhp assembly and use it generate a manifest.yml with name, version, description etc. pre-populated. If you haven’t added this information, then placeholders will be used.

The RhinoCommon plug-in inspector extracts the assembly attributes that you set when creating your plug-in. The AssemblyInformationalVersion attribute is used to populate the version field, since this attribute isn’t bound to the Microsoft four-digit version spec and can contain a SemVer-compatible version string. The AssemblyVersion attribute is used as a fallback.

Note
The spec command is useful for generating the manifest.yml file initially. Once you have one, keep it with your project and update it for each release.

Next, open the manifest file with your favourite editor and fill in the gaps.

Afterwards, you should have something that looks a little like this…

---
name: tamarin
version: 1.0.0
authors:
- Park Ranger
description: >
  This plug-in does something. I'm not really sure exactly what it's supposed to
  do, but it does it better than any other plug-in.  
url: https://example.com
icon: icon.png
keywords:
- something

Now that we have a manifest file, we can build the package!

> "C:\Program Files\Rhino 8\System\Yak.exe" build

Building package from contents of C:\Users\Bozo\dist

Found manifest.yml for package: tamarin (1.0.0)
Inspecting content: Tamarin.rhp
Creating tamarin-1.0.0-rh8_0-any.yak

---
name: tamarin
version: 1.0.0
authors:
- Will Pearson
description: >
  This plug-in does something. I'm not really sure exactly what it's supposed to
  do, but it does it better than any other plug-in.
url: https://example.com
keywords:
- something
- guid:c9beedb9-07ec-4974-a0a2-44670ddb17e4

C:\Users\Bozo\dist\tamarin-1.0.0-rh8_0-any.yak
├── manifest.yml
├── net48/
   ├── Tamarin.dll
   ├── Tamarin.rhp
   ├── icon.png
   └── misc/
       ├── License.txt
       └── README.md
└── net7.0/
    ├── Tamarin.dll
    ├── Tamarin.rhp
    ├── icon.png
    └── misc/
        ├── License.txt
        └── README.md
Note
The filename includes a “distribution tag” (in this case rh8_0-any). The first part, rh8_0, is inferred from the version of Rhinocommon.dll or Rhino C++ SDK that is referenced in the plug-in project. The second part, any, refers to the platform that the plug-in is intended for. To build a platform-specfic package, run the build command again with the --platform <platform> argument, where <platform> can be either win or mac.
Note
You might notice your plug-in’s GUID lurking in the keywords. More information on how this is used can be found in the “Package Restore in Grasshopper” guide.

Congratulations! 🙌 You’ve just created a multi-targeted package for your Rhino plug-in.

Next Steps

Now that you’ve created a package, push it to the package server to make it available in the package manager!