Skip to main content

Create project

Overview

When developing a .NET DLL extension, create a new project in Visual Studio and prepare the necessary files in that project. For example, when developing an extension named MyExtension using the .NET DLL method, the basic file structure is as follows.

Extension file structure
src/
MyExtension.sln
MyExtension/
MyExtension.csproj
manifest.json
main.cs
resources/
button.png

You can choose one of the following methods to create a new project.

  • Create a project using a project template.
  • Create a project manually.
Preparations

To develop an extension, you must have .NET 8.0 SDK installed.

Create a project using a project template

When developing with Visual Studio, we recommend using the Next Design extension development project template, as it significantly reduces the amount of work compared to the manual project creation method described below.

Installation

If you are using a project template for the first time, you must install it. Run the following command from the command prompt. You can run it in any directory.

dotnet new --install NextDesign.Extension.ProjectTemplates

Create a new project

Once you have installed the template, you will be able to create a project from Visual Studio. Start Visual Studio and select the extension development project from the new project creation dialog.

There are two types of project templates available, so please select Next Design Extension and create a project.

  • Next Design Extension ... This is a standard extension development project.
  • Next Design Extension (Extension Points) ... This is a project that uses the ExtensionPoints library, which makes it very simple to define extension points.
info
  • This topic assumes the use of standard extensions, but by using the Next Design Extension (Extension Points) template, you can develop manifest definitions and handler implementations simply. For details, see the ExtensionPoints library.

When you create a project, you can create a project that includes a manifest file and a sample implementation of the extension as follows.

Creating a project manually

The following describes how to create a new Visual Studio project and prepare the necessary files in the following order:

  • Create a new project
  • Register the DLL for extension development
  • Prepare a manifest file

Create a new project

  • Run [Create a new project] in Visual Studio to create a new project for class library development in C#.

Create a project with Visual Studio

  • Select [.NET 8.0] for the framework.

Create a project with Visual Studio 2

Set the target OS

In the project properties, set the target OS to "Windows".

Register DLLs for extension development

Get the following DLLs as NuGet packages. Select [Dependencies] for the project from the Visual Studio Solution Explorer and select [Manage NuGet Packages] from the context menu.

Make sure that the package source is set to nuget.org, and search for NextDesign in the [Reference] tab. The following packages will be displayed, so install them.

NextDesign.Core
NextDesign.Desktop

note

If the version of the above DLLs referenced in the extension development project does not match the version of the same DLLs installed in the execution environment where the extension is distributed, the extension may not work properly.

Manifest file

A Next Design extension requires one file named manifest.json. This is called a manifest. A Next Design extension defines its extension points in the manifest file (manifest.json). This manifest contains the following definitions:

  • Extension overview
  • Entry point file name
  • Lifecycle
  • Extension points for UI, events, and commands
manifest.json
{
"name": "MyExtension", //Specify a unique name to distinguish the extension.
"main": "MyExtension.dll", //Specify the DLL file name in which the extension (IExtension implementation class) is implemented.
"lifecycle": "application", //"application" for extensions that are valid from application startup to termination.

"extensionPoints": {
...
}
}
  • When you create a project using a project template, a manifest file with the DLL file name and other settings is automatically created.
  • If you create a project manually, create a manifest file using the following procedure.
  1. In the Visual Studio Solution Explorer, add a JSON file as a new item to the project and specify manifest.json as the name. Use UTF-8 as the character code for the manifest file.
  2. Select manifest.json in the Solution Explorer and set the property [Copy to output directory] to [Copy always] so that it is copied during the build.
  3. Define the contents of the manifest file.
  • Specify a unique name for all extensions in name. Defining it like MyCompany.MyExtension will make it less likely to cause a conflict.
  • For main, specify the name of the DLL file in which the extension (implementation class of IExtension) is implemented.
  • For lifecycle, specify project if the extension is for a specific project, or application otherwise.

For details on manifests, see Manifest Reference.

Prepare locale files (optional)

  • If you want to make your extension multilingual, define a locale file named locale.{lang}.json for each localized language.
  • For details on multilingual support, see Multilingual Support.

Change project settings (optional)

You can use the System.Windows.Forms namespace in your extension.
If you want to use it, set the UseWindowsForms attribute in the project file to true.
If you do not set the UseWindowsForms attribute to true, the System.Windows.Forms namespace will not be available and a build error will occur.

<!--csproj settings-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

</Project>