Debugging
When loading, the SyrveFront application searches for plugins and starts a process container Resto.Front.Api.Host.exe for each of them, within which the plugin will operate.
For debugging convenience, it is possible to run this process directly from the development environment. To do this, in the debugging settings of the plugin project, you need to specify the host process Resto.Front.Api.Host.exe as an external program and pass the following command-line arguments:
-a,--assembly=file — full path to the plugin file,-c,--class=name — full name of the plugin class (including namespace),-l,--log=log — full path to the log file,-m,--module=id — license module specified in thePluginLicenseModuleIdattribute (Licensing),-n,--nowindow— do not show the console window,-v,--version— version of the plugin (a string of 4 numbers separated by dots).
Next, you only need to run the SyrveFront application once (without installing the plugin in the Plugins folder), and you will be able to repeatedly start and stop the plugin directly from the development environment (F5 / Shift+F5 in Visual Studio, Alt-F5 in Rider), without restarting SyrveFront. The debugger will connect automatically, so breakpoints will work, and debugging will be interrupted when exceptions occur (in Visual Studio/Rider, you can configure which types of exceptions should or should not interrupt debugging). Log entries (PluginContext.Log) will be duplicated in the console window if it is not hidden by the --nowindow key, and in the Output window (Ctrl+Alt+O) if the debugger is connected.
To debug the plugin in this way, a plugin developer license is required.
Visual Studio
Classic .csproj
An example of filling in the fields on the Debug tab for a project in the old format:
- Start Action: Start external program:
C:\Program Files\Syrve\SyrveRMS\Front.Net\Resto.Front.Api.Host.exe. - Start Options: Command line arguments:
/a="C:\Projects\Front.Api Sdk\Resto.Front.Api.SamplePlugin\bin\Debug\Resto.Front.Api.SamplePlugin.dll" /c=Resto.Front.Api.SamplePlugin.SamplePlugin /m=21005108 /l="C:\Projects\Front.Api Sdk\Logs\sample-plugin.log"
SDK-style .csproj
For projects in the new format, the debugging parameters have moved to a separate file launchsettings.json, which can be created/edited both manually and through the UI: in the project properties Debug → General → Open debug launch profiles UI → Create a new profile → Executable. An example of the contents of launchsettings.json:
{
"profiles": {
"Resto.Front.Api.SamplePlugin": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Syrve\\SyrveRMS\\Front.Net\\Resto.Front.Api.Host.exe",
"commandLineArgs": "/a=\"C:\\Projects\\Front.Api Sdk\\Resto.Front.Api.SamplePlugin\\bin\\Debug\\Resto.Front.Api.SamplePlugin.dll\" /c=Resto.Front.Api.SamplePlugin.SamplePlugin /m=21005108 /l=\"C:\\Projects\\Front.Api Sdk\\Logs\\sample-plugin.log\""
}
}
}
Note for .NET Standard
Currently, there is a bug in Visual Studio that prevents debugging a plugin under .NET Standard when running it through the process container Resto.Front.Api.Host.exe, which is under .NET Framework.
Possible solutions:
- Build the plugin under .NET Framework
- Use Rider or another development environment where this bug does not exist.
- Add a dummy project under .NET Framework, set it as the startup project (Set as Startup Project), and specify the same debugging parameters as for the plugin. More details here.
Rider
JetBrains Rider allows you to set your own Debug Configurations with fields Exe path and Program arguments, as well as use the Visual Studio-compatible format launchsettings.json.
Alternative Options
If you do not have a plugin developer license, you will have to install the plugin in the Plugins folder so that the SyrveFront application launches it in the standard way, and each time you change the plugin, you will need to stop and restart the application. However, you can minimize the inconvenience as follows:
- In Visual Studio, in the project settings on the
Buildtab in theOutputsection, specify the path to the plugin’s subfolder in thePluginsfolder as theOutput path. This way, after each build, the plugin will be published to this folder immediately, and you will not have to copy it manually. - At the beginning of the plugin class constructor, add a call to
Debugger.Launch()to get a prompt to attach the debugger. You can, of course, attach it manually by selectingDebug → Attach to Processfrom the menu, but this will require more clicks, and you will also have to choose from several process containers with the same name.