Tutorials for Rhino/Grasshopper for mac on Visual Studio Code

I am developing a Grasshopper plugin using Visual Studio Code on a Mac, as Visual Studio for Mac will soon be retired. I have encountered significant challenges in the development process due to the scarcity of resources and guides for this specific environment. My primary issue is with the plugin not loading in Rhino WIP after compilation.

Development Environment:

  • OS: macOS 14.2.1 (23C71)
  • IDE: Visual Studio Code
  • Target Framework: .NET 8.0
  • Rhino Version: Version 8 (8.4.24044.15002, 2024-02-13)

Problem Description: After successfully compiling my C# code into a .gha file for a custom Grasshopper component, I placed the file in the Grasshopper Libraries folder. Despite following the expected procedures for plugin development, the component does not show up in the Grasshopper UI. There are no error messages or load errors dialogs upon startup in Grasshopper, and the component is missing from its designated category (“Utilities”) as well as other categories.

Also when on my script I run ‘run in WIP’ there is a compile error in rhino stating:
“Script server execute error:
Compile Error
The type or namespace name ‘Grasshopper’ could not be found (are you missing a using directive or an assembly reference?) (Error CS0246) file:///Users/jamesriggleman/code/c-sharp/HelloWorld/HelloWorld.cs:[2:7]
The type or namespace name ‘GH_Component’ could not be found (are you missing a using directive or an assembly reference?) (Error CS0246) file:///Users/jamesriggleman/code/c-sharp/HelloWorld/HelloWorld.cs:[5:36]
The type or namespace name ‘GH_InputParamManager’ could not be found (are you missing a using directive or an assembly reference?) (Error CS0246) file:///Users/jamesriggleman/code/c-sharp/HelloWorld/HelloWorld.cs:[14:49]
The type or namespace name ‘GH_OutputParamManager’ could not be found (are you missing a using directive or an assembly reference?) (Error CS0246) file:///Users/jamesriggleman/code/c-sharp/HelloWorld/HelloWorld.cs:[19:50]
The type or namespace name ‘IGH_DataAccess’ could not be found (are you missing a using directive or an assembly reference?) (Error CS0246) file:///Users/jamesriggleman/code/c-sharp/HelloWorld/HelloWorld.cs:[24:43]
‘HelloWorldComponent.Icon’: no suitable method found to override (Error CS0115) file:///Users/jamesriggleman/code/c-sharp/HelloWorld/HelloWorld.cs:[29:46]
‘HelloWorldComponent.ComponentGuid’: no suitable method found to override (Error CS0115) file:///Users/jamesriggleman/code/c-sharp/HelloWorld/HelloWorld.cs:[38:26]
‘GH_Component’ does not contain a constructor that takes 5 arguments (Error CS1729) file:///Users/jamesriggleman/code/c-sharp/HelloWorld/HelloWorld.cs:[8:9]”

It seems that in my vscode environment I am able to find the references to grasshopper and related packages, but once it tries compiling in rhino, there are compilation errors.

Complications:

  • The development workflow and resources for Grasshopper plugin development are scarce for Visual Studio Code, especially when compared to the retiring Visual Studio for Mac.
  • The absence of explicit documentation for plugin development in VS Code leads to uncertainty in project configuration and dependency management, particularly in ensuring the correct loading of plugins within Rhino WIP.

Request: I am seeking guidance or resources that could assist with Grasshopper plugin development in Visual Studio Code, especially in relation to:

  • Setting up the development environment in VS Code for Grasshopper plugin development.
  • Configuring project files (.csproj) to ensure compatibility with Rhino WIP.
  • Debugging and troubleshooting processes when the plugin does not load in Grasshopper.

Any help or direction to relevant resources would be greatly appreciated to bridge the gap caused by the transition from Visual Studio for Mac to Visual Studio Code for Grasshopper plugin development.

1 Like

ignore the part about the "run in wwip, Im mostly looking for guidance on this =>
Request: I am seeking guidance or resources that could assist with Grasshopper plugin development in Visual Studio Code, especially in relation to:

  • Setting up the development environment in VS Code for Grasshopper plugin development.
  • Configuring project files (.csproj) to ensure compatibility with Rhino WIP.
  • Debugging and troubleshooting processes when the plugin does not load in Grasshopper.
1 Like

hey James, have you found any tutorials for this?

Yeah, I’m facing this issue right now too. I’m trying to setup an automated build process on Ubuntu Linux.
Can anyone familiar with this help?

As someone who writes entire .NET applications, I can tell you that this is not really a problem of VSCode or Rhino. Sure setting up VSCode correctly for a project is a pain in any language. VSCode is too flexible for one-click solutions. But VS and Rider are essentially hiding the build process for you, which causes developers not to learn about the .NET build process at all. But this is important knowledge to have. Furthermore, developing .NET on Mac is also quite disappointing.

However the solution to your issues is simply by understanding the .NET build process for a dynamic library. So technically all you need to do is to reference Rhino libraries, implement the Plugin interface and compile a library in the right framework, rename it to .gha and copy it into a location where Rhino can load it from (or by adding additional paths to Rhino to search in). This is all it requires. There are many problems which can go wrong there, but I believe you can debug issues better if you understand the downfalls of the process better. Anyway, this is official documentation for it: