Project Setup (VS.Express) |
Please note that we now have Assembly Wizards for Grasshopper and it is no longer necessary to manually create a GHA project in Visual Studio.
If you are using the Express version of Visual Studio, then you might not be able to apply all required settings through the VS User Interface. In this case you'll have to modify the project files manually to apply the settings.
If you are using Visual Studio Professional, you can safely ignore this page.
This document outlines how to manually modify csproj and vbproj files.
It is useful to override the Visual Studio default behaviour regarding build configuration output. By default, DEBUG and RELEASE configurations (or 'flavours') are outputted to unique folders. This can cause confusion during debugging.
In order to override the output folders, open the project file in a text editor. If you're using VB then the project file will have the *.vbproj extension. If you're using C# then the project file will have the *.csproj extension. Ideally you should use a text editor that understands xml-formatting, but Notepad will do.
Inside the project file, locate the property group that has to do with the Debug and Release configurations. They will probably be called:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<OutputPath>bin\</OutputPath>
It is vital to add a Post-Build event to a Grasshopper Component Library since Grasshopper will only consider *.gha files during plug-in loading. Since your project is a Class Library, it will automatically be compiled into a *.dll file.
In order to override the output folders, open the project file in a text editor. If you're using VB then the project file will have the *.vbproj extension. If you're using C# then the project file will have the *.csproj extension. Ideally you should use a text editor that understands xml-formatting, but Notepad will do.
By default, a project file (vbproj for VB.NET; csproj for C#) does not contain any Build Events, so you'll have to add the entire section in the project file Xml data. Navigate towards the bottom of the project file. Just before the closing </Project> tag, insert the following PropertyGroup:
<PropertyGroup> <PostBuildEvent>Copy "$(TargetPath)" "$(TargetDir)\$(ProjectName).gha" Erase "$(TargetPath)" </PostBuildEvent> </PropertyGroup>
It is not possible to directly debug a Grasshopper Component Library, since it must be loaded by Grasshopper, which in turn must be loaded by Rhinoceros. So, in order to debug a *.gha file you must first start Rhino. This is called a Debug Start Action and VS Express does not allow you to set one via its own UI.
TODO, Finish this topic...