Building a dll in Visual Studio Mac - DLL to GHA

Hi all,

I am building a class library in Visual Studio Mac for Grasshopper 7.0. The C# solution structure is as attached below - a project for a component, and the other for a Class library, so I am expecting one GHA and a DLL. When building, VS creates two GHAs instead. How can I force VS not to change the extension of the DLL for the class library? I have nothing set up for the post/pre-build event, and no target extension in XML, but just installed the Grasshopper template for RH7. Any thoughts?

Why do not simply create a new class library? And delete one made by template.

Changes often often happens on prebuild events.

Oh, the class library was not automatically generated by the template. I added it from the scratch after creating the project/solution for the components.

I see the dll in the obj/debug folder and it changes the extension while being copied to the bin/debug folder. Do you know how to control this?

Check again two windows post build and pre build.
In one of those renaming happens using macros.

Thanks for the reply. I double-checked that there is no post/pre-build event set for the class library. Any other places that I should look at?

You can add a <Copy> task if you want to copy a file (and rename that target). Here is how I copy files, the approach works on both Windows and Mac. Look in particular at the second and third usages of <Copy>, there you can see how I rename files while copying.

In your case you want to do the copying after building is done, so create the target to be set to after build

1 Like

I was actually questioning if there is a pre-defined hidden command changing DLL’s extension into GHA in the Grasshopper Template for Visual Studio Mac. I have never had this issue with the Windows version. Anyways, thank you and I will give it a shot.

Look in the csproj to see if there is a tag <TargetExt> set to .gha.

1 Like

I see the <TargetExt> set to .gha in csproj file for the components, which is understandable, but I don’t see it in the csproj file for the class library, which puzzles me why the DLL keeps changing its extension.

If you attach the source of the class library csproj file we can have a better look.

I cannot share the file because of the NDA, but here is how to reproduce the issue.

  1. Create a new solution and project with the Grasshopper Plugin template (Update NuGet Packages for both Rhinocommon and Grasshopper).
  2. Add the new Library (Other → .Net → General).
  3. Up to this point, when you build it gives you the DLL.
  4. Install Rhinocommon from NuGet package manager for the class library.
  5. Then when you build, it changes its extension to RHP (bin/Debug) - I see DLL under obj/Debug).
  6. Install Grasshopper from NuGet package manager for the class library.
  7. Then when you build, it changes its extension to GHA (bin/Debug) - I also see DLL under obj/Debug).

So, I am speculating that installing Rhinocommon & Grasshopper from NuGet package manager for the class library adds some sort of hidden command to force changing the extension to whatever they prefer in lieu of DLL while copying the DLL from obj/Debug to bin/Debug.

Right, I don’t use the nuget packages, but I believe both packages come with property sheets that will have some settings that will cause this.

I think that if you include a <PropertyGroup> section after the nuget package references in your csproj and put a <TargetExt> in there you’ll be able to set it to .dll.

I will give it a shot. Thank you for your support on this, I really appreciate it.