This example demonstrates how to a simple C# library project. We’ll use pre-existing projects from SimpleLibrary example located here.
SimpleLibrary is a library project that consists of a single .cs source file SimpleLibrary.cs and a project file SimpleLibrary.csproj. This project does not depend on any other C# projects. SimpleLibrary project’s configuration file is pre-created, its name is SimpleLibrary.porter.config and it is located in the project’s directory SimpleLibrary. Let us have a closer look at the configuration file.
SimpleLibrary.porter.config file is quite simple. It begins with an XML declaration, which specifies that the file contains an XML document
Then goes the XML root element <porter> which is mandatory for Porter configuration XML document
Next, the default Porter configuration file is imported using <import> element. The default configuration will assign default values to all configuration options
Finally the XML document is finished with closing tag of the root element <porter></porter>
This example assumes that C# SimpleLibrary project should be ported into C++ static library project, which is a default setting.
With the C# project at hand and configuration file ready, we can convert the project.
In order to covert ComplexConsoleApp project we run CMD and navigate to the directory with porter binary:
Porter will print some logs of the porting process to the console window and when it finishes porting, directory C:\output will contain a directory named SimpleLibrary.Cpp containing the generated C++ source files and Cmake configuration files.
Now we want to use Cmake to generate makefile/project files. Let it be a Visual Studio 2017 x86 project file. In CMD we navigate to the C:\output\SimpleLibrary.Cpp directory
And run Cmake in configuration mode:
>Cmake --G "Visual Studio 15 2017"
And now we can build the sources using either Cmake or Visual Studio. Let us use Cmake: