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?
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?
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
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.
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.
I cannot share the file because of the NDA, but here is how to reproduce the issue.
Create a new solution and project with the Grasshopper Plugin template (Update NuGet Packages for both Rhinocommon and Grasshopper).
Add the new Library (Other → .Net → General).
Up to this point, when you build it gives you the DLL.
Install Rhinocommon from NuGet package manager for the class library.
Then when you build, it changes its extension to RHP (bin/Debug) - I see DLL under obj/Debug).
Install Grasshopper from NuGet package manager for the class library.
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.