Developing .NET Standard Libraries
The Synergy “Class Library (.NET Standard)” project template enables you to create class libraries that can be used for multiple platforms. Synergy .NET Standard libraries can run with .NET Framework (on Windows) and .NET 6 and higher (on Windows or Linux).
|
Projects created from the Synergy “Class Library (.NET Standard)” template automatically include the Synergex.SynergyDE.synrnt and Synergex.SynergyDE.Build NuGet packages, which are required. When a Synergy .NET Standard project is created, the latest packages (that are not pre-release) are downloaded to a local NuGet repository for the project. To update NuGet packages for existing projects, you must use the NuGet Package Manager or a .NET CLI command (“dotnet...”). See Microsoft documentation for more information (e.g., Install and manage packages in Visual Studio using the NuGet Package Manager).
|
The following steps outline the basic procedure for using Visual Studio to create a .NET Standard class library. Most of these steps outline Visual Studio procedures, so see Visual Studio documentation for more information. Additionally, note that the Synergy .NET Standard project template, “Class Library (.NET Standard)”, and project item templates are available in NuGet packages (Synergex.Projects.Templates and Synergex.ProjectItem.Templates) which can be used to develop Synergy .NET Standard projects with the .NET CLI. For information on developing with the .NET CLI, see Microsoft documentation and the “Basic .NET CLI development steps” sections in Developing for .NET 6 or Higher and Developing for .NET Framework.
|
2.
|
In Visual Studio, open the solution for the application you want to add the library to, and then select File > New > Project from the Visual Studio menu. |
|
3.
|
In the New Project window, select the “Class Library (.NET Standard)” template. (You can use the New Project dialog’s search field to find this.) Set options as necessary (e.g., specify the name of the project), and then click OK. |
The project is added to the solution that is currently open, and you can see a node for the project in Solution Explorer. (Select View > Solution Explorer to open Solution Explorer.) For more information on projects and solutions, see Projects for Synergy .NET.
|
4.
|
Add DBL code, resources, and other items to the .NET Standard library project, and make sure it references any needed assemblies. See Synergy/DE item templates for information on new items you can add to a project, and note the following: |
- For information on supported Synergy features, see Synergy DBL Support for .NET.
- For information on licensing, see Licensing .NET assemblies.
- See Performing Common Synergy .NET Coding Tasks for information on instantiating and using a .NET class, inheriting and overriding a .NET class, and more.
- For Interop projects, Synergy global structures used as attribute arguments must be defined in an assembly outside of a namespace.
- Use ASYNC routines for communication across networks and the internet. See Asynchronous processing (.NET) for more information.
- To use the Repository subroutine library, use the Synergex.SynergyDE.ddlib NuGet package. To use the XML API, use the Synergex.SynergyDE.synxml NuGet package.
- To generate documentation from comments in code, use ;;; to identify documentation comments in your code, and select the “XML documentation file” option on the Build page of project properties.
|
6.
|
Build and debug the solution. See Microsoft documentation for information on build features and the debugger. See Debugging Synergy .NET Code for debugging information specific to Synergy .NET. And see the Project Only information in SDI features for information on commands that enable you to build or rebuild (or clean) an individual project without affecting other projects in the solution, even referenced projects. |
Note that you can create a NuGet package for a Synergy .NET Standard project by using the nuget pack command. For example:
nuget pack MyProject.synproj
For more information, see Microsoft documentation on the nuget.exe CLI.