68 | | Save and close the project's properties. These changes ensure that the generated plugin is automatically added as a plugin to the HeuristicLab build and that we can use our solution to start a debugging session (shortcut <F5>). Now, we want to make this class library a HeuristicLab plugin. |
| 68 | Save and close the project's properties. These changes ensure that the generated plugin is automatically added as a plugin to the HeuristicLab build and that we can use our solution to start a debugging session (shortcut <F5>). |
| 69 | |
| 70 | == Add plugin class == |
| 71 | Now, we want to make this class library a HeuristicLab plugin at which point we need to create a plugin class. |
| 72 | |
| 73 | === References === |
| 74 | Every plugin has at least a reference to the PluginInfrastructure which is needed by the plugin class that we are creating. |
| 75 | |
| 76 | * For the project add a reference to HeuristicLab.PluginInfrastructure.dll in StableRoot\bin by right-clicking on "References" choosing "Add Reference" and select the ".NET Assembly Browser" tab. |
| 77 | * '''Important:'' Since we're building into a common bin folder you have to open the properties of this reference and set '''"Local copy" to false''' |
| 78 | |
| 79 | Visual Studio has already created a cs file when creating the project. Rename this file to Plugin.cs: |
| 80 | |
| 81 | [[Image(solution_sd.png)]] |
| 82 | |
| 83 | Every HeuristicLab plugin needs a Plugin file. This file contains information about the plugin itself (Name, Filename, Version) and it's dependencies. The dependencies are used by the plugin infrastructure to check if all required plugins for a certain plugin are found. Therefore we will write the following code in our Plugin.cs file: |
| 84 | |
| 85 | {{{ |
| 86 | #!csharp |
| 87 | using HeuristicLab.PluginInfrastructure; |
| 88 | |
| 89 | namespace HeuristicLab.GreatIdea.ThePlugin { |
| 90 | [Plugin("HeuristicLab.GreatIdea.ThePlugin", "Provides an implementation of a great idea", "3.3.9.0")] |
| 91 | [PluginFile("HeuristicLab.GreatIdea.ThePlugin.dll", PluginFileType.Assembly)] |
| 92 | public class Plugin : PluginBase { |
| 93 | } |
| 94 | } |
| 95 | }}} |
| 96 | |
| 97 | '''Important:''' The plugin class needs to derive from HeuristicLab.PluginInfrastructure.PluginBase so that the dll is realized as a plugin. The attributes specify the details of the plugin and which files it provides. The filename given in PluginFile has to be the same as the assembly output filename in the "Application" tab of the project's properties. |
| 98 | |
| 99 | '''Important:''' Changing major or minor version numbers in the course of development marks a breaking change to previously saved files. If HeuristicLab wants to load an item of a plugin with version 3.3.8 it will accept the same plugin in version 3.3.9 to open it. However, it will reject the plugin when its major or minor is different (e.g. 3.2.7, 3.4.3 or 4.0.1). The "Assembly file version" is not used by HeuristicLab and can be set without any restrictions. |