= Quick guide: Create a new plugin with Visual Studio = We assume that you have obtained the source as described in Quick guide: Download and build sources. We assume your directory structure looks as follows: [[Image(/raw-attachment/wiki/Documentation/DevelopmentCenter/CreateNewPluginWithVS/working_dir.png)]] == A new solution == We will now create a new SharpDevelop solution and add a class library project which will become the HeuristicLab plugin. * In SharpDevelop select "File > New > Solution..." or press * Use the "Class Library" template * In this guide we'll use "GreatIdea" as solution name and choose the extension folder as location, the plugin will be named "HeuristicLab.GreatIdea.ThePlugin" [[Image(create_project_sd.png, align=center)]] Your working directory should now look something like this [[Image(/raw-attachment/wiki/Documentation/DevelopmentCenter/CreateNewPluginWithVS/working_dir_new.png)]] == Configuring the project == '''Assembly information''' In the projects tree view on the left you will see a folder "Properties" below the project with a file AssemblyInfo.cs. Edit that file. In HeuristicLab 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. {{{ #!csharp using System; using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyTitle("HeuristicLab.GreatIdea.ThePlugin")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HEAL")] [assembly: AssemblyProduct("HeuristicLab")] [assembly: AssemblyCopyright("(c) 2002-2014 HEAL")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] // The assembly version has following format : // // Major.Minor.Build.Revision // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: [assembly: AssemblyVersion("3.3.0.0")] [assembly: AssemblyFileVersion("3.3.9.0")] }}} '''Project properties''' In the project's properties (right-click on the project) we configure: Signing, compiling, and debug. If you open the properties please also make sure the target framework is set to .NET Framework 4.0. '''Signing''' Activate "Sign the assembly" and create a new key or browse to use the HeuristicLab.snk inside the plugins of StableRoot. Otherwise call the new key "TheKey". '''Compiling''' We want to automatically put the plugin into the StableRoot\bin folder when we compile it. On the "Compiling" tab change the output path to `..\..\..\stable\bin`, click on the small dot button in front and remove the check in front of "Configuration-specific" so that this options holds regardless of which platform or configuration we build for. [[Image(output_path.png, align=center)]] '''Debug''' On the "Debug" tab choose "Start external program" and select HeuristicLab.exe inside StableRoot\bin. Again remove the "Configuration-specific" check and instead add a check to "Store in .user-file". 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 ). == Add plugin class == Now, we want to make this class library a HeuristicLab plugin at which point we need to create a plugin class. === References === Every plugin has at least a reference to the PluginInfrastructure which is needed by the plugin class that we are creating. * 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. * '''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''' Visual Studio has already created a cs file when creating the project. Rename this file to Plugin.cs: [[Image(solution_sd.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 we will write the following code in our Plugin.cs file: {{{ #!csharp using HeuristicLab.PluginInfrastructure; namespace HeuristicLab.GreatIdea.ThePlugin { [Plugin("HeuristicLab.GreatIdea.ThePlugin", "Provides an implementation of a great idea", "3.3.9.0")] [PluginFile("HeuristicLab.GreatIdea.ThePlugin.dll", PluginFileType.Assembly)] public class Plugin : PluginBase { } } }}} '''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. '''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. == Testing the plugin == * Build the project and press to start it without a debugger attached * You will see the starter window again, but you already know the switches to hide it * Inside the starter open the "Plugin Manager" and see that it is correctly loaded [[Image(/raw-attachment/wiki/Documentation/DevelopmentCenter/CreateNewPluginWithVS/plugin_manager.png, align=center)]] Now we have created an empty plugin that we can use to implement a new great idea. Please refer to the [[Documentation]] pages and the various HowTos on how to write views, operators, algorithms, etc.