menu
info Documentation

Development Environment

D2S2 scripts and custom models can be created using a C# environment within Visual Studio Code (VSCode).

Set Up VSCode for D2S2 Development

The steps below are similar to those described in the Getting Started Guide for C# in VSCode.

  • Download Visual Studio Code and install it.
  • After opening VSCode, go to Extensions and search for C# Dev Kit.
  • Install this extension — it will automatically also add the C# and .NET Install Tool extensions.
  • If prompted that a .NET SDK is not present, install the .NET 8.0 SDK from here. The x64 version is recommended.
  • To verify the SDK is correctly installed, open a terminal and run dotnet --help. If the command is not recognised, you need to add the .NET installation directory to your system's environment variables:
    • Open the File Explorer and navigate to This PC. Right-click in the window and select Properties, then go to Advanced system settings and select Environment Variables...
    • Under the Path variable, select Edit and add the path to the dotnet executable, which is installed by default at C:\Program Files\dotnet.

Create a New D2S2 Development Project

To effectively develop code that interacts with and uses the D2S2 infrastructure, the development code must be aware of the D2S2 libraries, and D2S2 must be aware of the location of the user-defined code.

  • Open D2S2 and select the User Settings option.

  • In the new window, select the Developer option. A number of additional fields will appear in the panel to the right (see Figure 1).

Figure 1: The Developer settings panel within the user settings.

  • Start by creating a new development profile. A profile saves a set of Development user settings for easy switching between configurations.
  • To define a new development folder, or to select a folder that already contains custom modules, use the folder prompt in the Source Directories panel. After D2S2 has set up the folder, it will contain a .csproj file that links to the necessary D2S2 libraries.
  • This folder can now be opened in VSCode, which will identify it as a C# project.
  • A new class file can be created in this folder to implement the required user-defined capabilities.
  • After any file change within the development folders, D2S2 will attempt to compile the updated source. Compilation errors are displayed in the bottom panel of the Model View panel (see Figure 2).

Figure 2: Error list within the Model View panel.