Create project
Overview
When developing a .NET DLL-style 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.
src/
MyExtension.sln
MyExtension/
MyExtension.csproj
manifest.json
main.cs
resources/
button.png
To create a new project, choose one of the following methods:
- Create a project using a project template.
- Create a project manually.
Extension development requires .NET 6.0 SDK to be installed.
Create a project using a project template
When developing with Visual Studio, using the project template for Next Design extension development greatly reduces the work compared to the manual project creation method described below, so we recommend using it.
install
Installation is required when using the project template for the first time. Execute the following command from the command prompt. It doesn't matter which directory you run it in.
dotnet new --install NextDesign.Extension.ProjectTemplates
Create a new project
After installing the template, you will be able to create a project from Visual Studio. Start Visual Studio and select Extension Development Project from the New Project dialog.
The following two types of project templates are available, so select Next Design Extension
and create a project.
- Next Design Extension ... Standard extension development project.
- Next Design Extension (Extension Points) ... This project uses the ExtensionPoints library, which makes the definition of extension points very simple.
- This topic assumes the use of standard extensions, but the
Next Design Extension (Extension Points)
template simplifies the development of manifest definitions and handler implementations. See ExtensionPoints library for details.
When you create a project, you can create a project that includes a manifest file and a sample implementation of an extension as follows.
Create a project manually
Below, we will explain how to create a new Visual Studio project and prepare the necessary files in the following order.
- create a new project
- Register DLL for extension development
- Prepare manifest file
Create a new project
-
Run [Create New Project] in Visual Studio to create a new project for class library development using C#.
-
Select .NET 6.0 for Framework.
Register DLL for extension development
Get the following DLLs in the NuGet package. Select [Dependencies] of the project from Visual Studio's Solution Explorer and execute [Manage NuGet Packages] from the context menu.
Make sure that the package source is nuget.org
, enter NextDesign
in the [Reference] tab, search for it, and the following package will be displayed, so install it.
NextDesign.Core
NextDesign.Desktop
If the version of the above DLL referenced in the extension development project does not match the version of the same DLL installed in the execution environment of the extension distribution destination, the extension may not work properly.
manifest file
Next Design extensions require one file named manifest.json
. This is called a manifest. Next Design extensions define extension points in the manifest file (manifest.json
). This manifest contains the following definitions:
- Overview of extensions
- file name as entry point
- life cycle
- Extension points for UI, events and commands
{
"name": "MyExtension", //Specify a unique name to distinguish your extension.
"main": "MyExtension.dll", //Specify the DLL file name where the extension (IExtension implementation class) is implemented.
"lifecycle": "application", //"application" for extensions that are valid from application startup to shutdown,
"extensionPoints": {
...
}
}
- When a project is created using a project template, a manifest file with DLL file names and other settings is automatically created.
- If you created the project manually, follow the steps below to create the manifest file.
- In Visual Studio's Solution Explorer, add a JSON file as a new item to your project and name it
manifest.json
. Please use UTF-8 for the character code of the manifest file. - Select
manifest.json
in the solution explorer and set the property [Copy to output directory] to [Copy always] so that it will be copied at build time. - Define the contents of the manifest file.
- Specify a unique name for all extensions in
name
. A definition likeMyCompany.MyExtension
is less likely to clash. - For
main
, specify the name of the DLL file where the extension (IExtension implementation class) is implemented. - For
lifecycle
, specifyproject
if the extension is for a specific project, otherwise specifyapplication
.
- Specify a unique name for all extensions in
- In Visual Studio's Solution Explorer, add a JSON file as a new item to your project and name it
For more information about manifests, see Manifest reference.
Prepare locale files (optional)
- If you want your extension to be multilingual, define a locale file named
locale.{lang}.json
for each localized language. - For more information on multi-language support, see multi-language support.
Change project settings (optional)
Extensions can use the System.Windows.Forms
namespace.
To use it, set the UseWindowsForms
attribute in the project file to true
.
If the UseWindowsForms
attribute is not set to true
, the System.Windows.Forms
namespace will not be available and will result in a build error.
<!--csproj settings-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>