= Quick guide: Create a new plugin with Visual Studio = We assume that you have obtained the source as described in [[Documentation/DevelopmentCenter/DownloadAndBuildSource|Quick guide: Download and build sources]]. We assume your directory structure looks as follows: [[Image(working_dir.png)]] == A new solution == We will now create a new Visual Studio solution and add a class library project which will become the HeuristicLab plugin. * In Visual Studio select "File > New > Project..." or press * Use the "Blank Solution" template * In this guide we'll use "GreatIdea" as name and choose the `extension` folder as location [[Image(create_solution.png, 70%, align=center)]] Next we add a new project to this solution. * In the Solution Explorer right-click the "GreatIdea" solution and select "Add > New Project..." * On the right choose "Visual C#" and select the "Class Library" template * In this guide we'll pick "HeuristicLab.GreatIdea.ThePlugin" Your working directory should now look something like this: [[Image(working_dir_new.png)]] == Configuring the project == === Project properties === In the project's properties we configure: Assembly information, build, debug, and signing. If you open the properties please also make sure the //target framework// is set to .NET Framework 4.0. [[Image(assembly_info.png, 30%, align=right, margin-left=30)]] '''Assembly information''' We set the assembly version to the same value as the current HeuristicLab version by convention. It should only include major and minor, build and revision should always remain 0. In the official HeuristicLab repository the revision part is synchronized with the SVN revision number, it can be simply set to 0 in our case. The assembly file version can include the whole version string. '''Build''' We want to automatically put the plugin into the StableRoot\bin folder when we compile it. On the "Build" tab change the configuration box from "Active (Debug)" to "All Configurations" and enter `..\..\..\stable\bin` in the output path. '''Debug''' On the "Debug" tab choose "Start external program" and select HeuristicLab.exe inside StableRoot\bin - this setting is stored in the .csproj.user file. [[Image(debug_options.png, align=center)]] '''Signing''' Activate "Sign the assembly" and create a new key or use the HeuristicLab.snk inside the plugins of StableRoot. Otherwise call the new key "TheKey", but deselect the password option. 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 ). Now, we want to make this class library a HeuristicLab plugin. === References === Every plugin has at least a reference to HeuristicLab.PluginInfrastructure as this is needed for the Plugin.cs file. Therefore add a reference to this plugin: [[Image(add_reference.png)]] === Plugin file === Visual Studio has already created a cs file when creating the project. Rename this file to Plugin.cs: [[Image(solution.png)]] 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 write the following code in your Plugin.cs file: {{{#!csharp using HeuristicLab.PluginInfrastructure; namespace HeuristicLab.Algorithms.MyAlgorithm { [Plugin("HeuristicLab.Algorithms.MyAlgorithm", "1.0.0.0")] [PluginFile("HeuristicLab.Algorithms.MyAlgorithm.dll", PluginFileType.Assembly)] public class MyAlgorithmPlugin : PluginBase { } } }}} '''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. === Build path === The last step is to adjust the output path for the plugin. Because we don't want to copy the plugin file by hand to the HeuristicLab bin directory, we set the output path to this location so that it gets directly built there. Right click on your project, choose Properties and then the Build register card: [[Image(output_path.png)]] The output path is set as a relative path. This makes it possible for other people who may have a different directory layout (e.g. no C:\HL\) to also build the project. == Testing the plugin == You should now be able to compile your project and find your plugin file in the HeuristicLab bin folder. To test if everything works and the plugin infrastructure recognizes the plugin, start !HeuristicLab an double click the Plugin Manager application in the Starter dialog. Your plugin should be listed under "Active Plugins": [[Image(plugin_manager.png)]] == Where to go from here == Take a look at [[wiki:UsersHowtosImplementAnAlgorithm| this page]] which describes how to create a basic HL algorithm.