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.)

Note

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.

1. Start by reviewing Synergy .NET Requirements and the Synergy DBL Integration Requirements page. Then set options for your Visual Studio environment as necessary. For example, you can control the behavior of the Visual Studio code editor (indentation, tab size, etc.), the way IntelliSense works for Synergy DBL files, and which file types are automatically treated as compile or content files. See Options for Synergy/DE projects 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:
4. Set project properties, which include settings for licensing, deployment, and building/compiling. See Synergy/DE project properties. For information on setting environment variables for a project, see Environment variables and Visual Studio development.

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.
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.

1. Whether you deploy to Windows or Linux, you'll develop on a Windows machine. Make sure that machine meets the requirements listed in Synergy .NET Requirements and the Synergy DBL Integration Requirements page.
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).
Template name Short name
Class Library (.NET) synNETLib
Class Library (.NET Standard) synNETStandardLib
Console App (.NET) synNETApp
Multiple Mainline (.NET) synNetMutiMainine
Script synScriptProj
Synergy/DE Repository synRepoProj
Unit Test (.NET) synNETUnitTest

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).
6. For the final, deployable build, use the “dotnet publish” command. See step 6 in Basic development steps in Visual Studio above.
7. Deploy to machines that meet deployment requirements (including licensing requirements) listed in Synergy .NET Requirements. For information on creating a NuGet package for a Synergy project, see step 7 in Basic development steps in Visual Studio above.