Mac VisualStudio add References


I am trying to load a project in Visual Studio Mac, but I cannot reference RhinoCommon properly.

I tried to install Rhinocommon via package manager but the reference is till not recognised. How can I reference assemblies in Mac Visual Studio?

Hi @Petras1, it’s been a long time since I did it, but I believe everything is explained there : Installing Tools (Mac) with C#
Install the tools found there and load it then from visual studio>extensions

Thanks for the tutorial @flixchameroy . The tutotial is about creating a new project based on a template.

But how do you reference rhinocommon for an empty c# ? I am a newbie on mac and possibly missing smth simple.

On the menu bar, go to Project>Add Reference ?

And for mac I can reference the same rhinocommon.dll? Is this .dll typically found in application folder?

I’m really no specialist but I think yes.

RhinoCommon.dll is typically found at /Applications/Rhino, you can browse to there while adding a .Net Assembly

You might also need RhinoUi.dll which you can find in the same folder, and Grasshopper.dll or GH_IO.dll, which you’ll get at /Applications/Rhino

1 Like

Thank you it helps a lot.

I am trying to build OpenNest.gha but it gives me following error. Any ideas why building could fail?

Looks like renaming from .dll to .gha fails but no idea why.

It seems windows visual studio projects dont simply work on mac. It only works if I create new grasshopper visual studio project and copy paste the .cs files.

The .csproj format is cross-platform, but older projects may use platform-specific elements such as post-build steps that rely on commands that are only present on one operating system (i.e. Copy).

Here’s an example of a cross-platform .csproj (using the modern sdk-style format) that’s generated by the current Rhino 7 C# project template

<Project Sdk="Microsoft.NET.Sdk">
    <Description>Description of rhino_test</Description>
    <PackageReference Include="Grasshopper" Version="7.4.21078.1001" IncludeAssets="compile;build" />
  <PropertyGroup Condition="$(Configuration) == 'Debug' AND $([MSBuild]::IsOSPlatform(Windows))">
    <StartProgram>C:\Program Files\Rhino 7\System\Rhino.exe</StartProgram>


It uses TargetExt to set the extension instead of a post-build step.

1 Like

Thank you @will
It seems that my project is 2-3 years old, meaning this post-build was causing troubles. I am glad the newer template is more cross-platform friendly.