Launch.json vs .csproj

Hello,

I’m quite new to component development with visual studio 2022 and have following problem:

I can’t get Rhino 8 to start with grasshopper and a specific file via the .csproj settings like this:

<PropertyGroup Condition="$(Configuration) == 'Debug' AND $([MSBuild]::IsOSPlatform(Windows))">
 <StartProgram>C:\Program Files\Rhino 8\System\Rhino.exe</StartProgram>
 <StartArguments>
  /netfx /runscript="_-RunScript (
  Set GH = Rhino.GetPlugInObject(""Grasshopper"")
  Call GH.OpenDocument(""C:\Users\MoeldersLeo\Desktop\testing.gh"")
  )"
 </StartArguments>
 <StartAction>Program</StartAction>
</PropertyGroup>

My launch.json looks like this:

{
  "profiles": {
    "Win Rhino 8 net48": {
      "commandName": "Executable",
      "executablePath": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe",
      "commandLineArgs": "/netfx"
    }
  }
}

Without this commandLineArgs “/netfx” I get the NetCore error. How can I get this to run and respect the settings from csproj?

Thanks in advance for your help :slight_smile:

Hi @Lennard92

I beleive the Launch.json replaces or overrides that part of the .csproj file in the newer C# project templates so you need to move the StartArguments into commandLineArgs

The trick becomes that you will need to escape all of the characters.
I think this tool may help Free Online JSON Escape / Unescape Tool - FreeFormatter.com

Maybe this is close? It is not quite right but i do not have enough knowledge of Rhino Script to fix but hopefully it helps you along the path - good luck!

  "profiles": {
    "Rhino 8 - .net 7": {
      "commandName": "Executable",
      "executablePath": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe",
"commandLineArgs": "/netcore /nosplash  /runscript=\"_-RunScript (\r\n  Set GH = Rhino.GetPlugInObject(\"\"Grasshopper\"\")\r\n  Call GH.OpenDocument(\"\"C:\\Users\\MoeldersLeo\\Desktop\\testing.gh\"\")\r\n  )\""
    }
  }
}
1 Like

Hi @david.birch.uk,

I already have it running from there like this:

I’m just curious why the other solution does not work for me, as I have seen it working here:

1 Like

I have a follow up question:

When I run Rhino via cmd from its directory with “/nosplash” it opens without splash screen as expected, but when I add “/nosplash” to the command above from Visual Studio it returns a plugin error before starting:

grafik

and another error when it finished loading:

grafik

Furthermore it does not open the grasshopper file.

Anybody an idea?

I can’t seem to get either method to work. I’m on MacOS, so I believe I need -arg instead of \arg, and confirmed this by launching Rhino from a Terminal. I watched the video “5.9 Speeding Up…”, and I’ve tried putting -runscript="_Grasshopper", with and without escaped quotes, in various places, all no dice; it never has an effect. It would significantly speed my development to get this working. I’d love some help!

I got it. I’m using Properties/launchSettings.json, and I had something wrong.

This is what I had that wasn’t working:

{
  "profiles": {
    "BertiniReal": {
      "commandName": "Executable",
      "executablePath": "/Users/amethyst/Applications/Rhino 8.app",
      "commandLineArgs": "-runscript=\"_New _Grasshopper\""
    }
  }
}

The following worked for me!!!

{
  "profiles": {
    "BertiniReal": {
      "commandName": "Project",
      "executablePath": "/Users/amethyst/Applications/Rhino 8.app",
      "commandLineArgs": "-runscript=\"_New _Grasshopper\""
    }
  }
}

I was able to know to change Executable to Project from this VS documentation page, which says:

If launchSettingsProfile is NOT specified, the first profile with "commandName": "Project" will be used.

1 Like

To more completely document this for myself, here are three screencaps to help:

First, the Rhino tab with a gear :gear: under Build for my project:

Second, the Default Configuration under Run:

Third, the launchSettings.json file:

It’s important that I took out the “executablePath” from my previous post, as that was causing Grasshopper to not see my .gha file and then the whole thing was pointless.


Now I can really :guitar: by making a re-usable .gh file for testing. Thanks!

Glad to see you’re rockin @silviana_amethyst, just so you know Visual Studio for Mac is being discontinued in late August 2024. Here are some nice shiny docs on using vscode.

I’ll follow up and say that my launchSettings.json was left over from my student doing development on a Windows machine. I worked hard to find that Project value. My new student, also doing development on a Windows machine, had to (of course) remove the hardcoded file path to the rhino executable. But then VS changed Project back to Executable.

So, now I’m fighting for space in the launchSettings.json file. I think I might need a profile for Windows and a profile for Mac.

1 Like

I usually create Windows/Mac specific launch jsons for either vscode or vs. There’s a few differences here and there that just make this easier :slight_smile:

For windows you should find a working launchSettings.json in this Visual Studio extension Project templates for Rhino 3D - Visual Studio Marketplace

1 Like