Developing for .NET 6 or Higher
With Synergy .NET, you can create console applications and libraries for .NET 6 and higher on Windows and Linux. This topic, which includes the following sections, outlines the basic development steps for .NET 6 and higher:
Version 6 and higher of .NET are generally updated more quickly than .NET Framework, and applications for .NET 6 and higher generally take less memory, run faster, and make for smaller deployments than equivalent .NET Framework applications. Additionally, if you create a self-contained deployment, changes to .NET versions on deployment machines will not affect your application. For more information, see Microsoft documentation for .NET (e.g., .NET fundamentals documentation.)
|
Synergy projects created for .NET 6 and higher automatically include the Synergex.SynergyDE.synrnt and Synergex.SynergyDE.Build NuGet packages, which are required. When one of these projects 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).
|
Basic development steps in Visual Studio
The following steps outline the basic procedure for using Visual Studio to create a Synergy application for .NET 6 or higher. Most of these steps outline Visual Studio procedures, so see Visual Studio documentation for more information.
|
2.
|
In Visual Studio, create a project for each assembly in your application, and put all the projects for your application in one solution. You can use the following project templates: |
Console App (.NET)
Class Library (.NET)
Class Library (.NET Standard)
Multiple Mainline (.NET)
Script
Synergy/DE Repository
Unit Test (.NET)
For example, to create a console application, select File > New > Project in Visual Studio. Then select the “Console Application (.NET)” template. (You can use the New Project dialog’s search field to find this.) See Synergy projects, solutions, and files for more information, and note the following:
|
3.
|
Add DBL code, resources, and other items to the Visual Studio projects for your application, and make sure each project 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 which Synergy features are supported, see Synergy DBL Support for .NET.
- 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 information on adding references or dependencies to Synergy repositories, see Using Synergy/DE repositories in Visual Studio.
- Use ASYNC routines for communication across networks and the internet. See Asynchronous processing (.NET) for more information.
- Synergy .NET 6 and higher assemblies require traditional Synergy licensing. (Device licensing is not supported only for .NET Framework.) See Licensing .NET assemblies.
- 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.
Note that for Multiple Mainline projects, the “Startup object” field on the Application page of project properties determines which mainline is used as the starting point when you select a Visual Studio debug or run option. You can also set this by right-clicking a source file in Visual Studio’s Solution Explorer and selecting “Set as Startup Object” from the context menu.
|
5.
|
Create preliminary builds and debug the project in Visual Studio using Visual Studio build and debug commands.
|
- For more information on building and debugging, see Microsoft documentation.
- For debugging information specific to Synergy .NET, see Debugging Synergy .NET Code.
- For information on Build menu commands that enable you to build or rebuild (or clean) an individual project without affecting other projects in the solution (even referenced projects), see the “Project Only” information in SDI features.
|
6.
|
For the final, deployable build, use the “publish” command. See Microsoft documentation (e.g., Publish .NET apps with the .NET CLI). The publish command enables you to create self-contained or framework-dependent builds. For example, when the following command is run in the same directory as the solution, it creates a self-contained build (an .exe file) for Windows x64: |
dotnet publish -c Release -r win10-x64
|
7.
|
Deploy to machines that meet deployment requirements (including licensing requirements) listed in Synergy .NET Requirements. |
Note that you can create a NuGet package for a Synergy .NET 6 or higher project by using the nuget pack command. For example:
nuget pack MyProject.synproj
For more information, see Microsoft documentation on the nuget.exe CLI.
Basic .NET CLI development steps
The following steps outline a basic procedure for using the .NET CLI (i.e., "dotnet" commands) to create a Synergy application for .NET 6 or higher. Most of these steps outline .NET CLI procedures, so see Microsoft documentation on the .NET CLI for more information.
|
2.
|
Use the following commands to install the Synergy project and item templates, which are available in nuget.org: |
dotnet new install Synergex.Projects.Templates
dotnet new install Synergex.ProjectItem.Templates
If you get an error such as “Synergex.ProjectItem.Templates could not be installed, the package does not exist”, the problem could be that the NuGet feed (https://api.nuget.org/v3/index.json) is not set up as a package source on your system. See Microsoft documentation on package sources for information on adding this package source.
|
3.
|
Use the “dotnet new template_shortname” command (where template_shortname is one of the names listed in the “Short name” column below) to create a project for each assembly in your application. And put all the projects for your application in one solution (e.g., by using “dotnet new sn -n solutionName” to create a solution, and by using “dotnet sln add projectPathAndName” to add a project to a solution). |
For example, the following command creates a new Synergy .NET console app named TestApp:
dotnet new SynNETApp -n TestApp
|
4.
|
Once you have created projects and a solution, you can add DBL code, resources, and other items to the projects, and you can set project properties. It’s generally best to do this in Visual Studio (see step 3 and step 4 in Basic development steps in Visual Studio above), but you can use .NET CLI commands, modify project files, etc. |
|
5.
|
Do preliminary builds, running, and debugging in Visual Studio. See step 5 in Basic development steps in Visual Studio above. Alternatively, you can do some of these tasks with the .NET CLI (e.g., you can use “dotnet run” to run the built project). |