Skyline DataMiner Web Application Project
A DataMiner web application is a standalone (static) website that fully runs in the browser. It is developed in a separate project, typically a JavaScript project (.esproj), and deployed by including it in a DataMiner Package Project.
Creating a web application project
You can create a new web application project with the DataMiner Web Application Project template, either in Visual Studio or using the .NET CLI:
dotnet new dataminer-web-application-project -o MyWebApplication
dotnet sln add MyWebApplication
Any .esproj or .csproj project can be used as a web application project, as long as it has the following project property:
<DataMinerType>WebApplication</DataMinerType>
App.info.json
Each web application project needs an App.info.json file in the root of the project. This file describes the web application:
{
"ID": "554e0e42-d497-49e9-b3c6-c00ea662b917",
"Name": "My Web Application",
"Description": "Example of a DataMiner web application.",
"Color": "#2563EB",
"Icon": "ms-Icon--Globe"
}
The following fields are mandatory:
- ID: A GUID that uniquely identifies the web application.
- Name: The name of the web application.
- Color: The color of the web application.
- Icon: The icon of the web application.
Optionally, you can also specify fields such as Description, DefaultDocument, Manifest, and Sections.
When a package is created, the SDK validates that the App.info.json file is present, that the mandatory fields have a value, and that the ID is a valid GUID. If this is not the case, the build of the package project fails.
Deploying a web application
A web application project does not produce its own DataMiner application package. To deploy it, include it in a DataMiner Package Project. By default, the ProjectReferences.xml file of a package project includes all .csproj and .esproj projects of the solution.
When the package project is built, the SDK does the following for each included web application project:
It builds the web application project. For .esproj projects, the Build target is used (e.g.,
npm run build). For other projects, the Publish target is used.It zips the output folder of the web application, together with the App.info.json file, into a file named <ProjectName>_<ID>.zip.
It adds this zip file to the package, in the AppInstallContent\ZipFiles\WebApp folder.
When the package is installed, the web application is installed on the DataMiner System. The default installation code (installerHelper.InstallDefaultContent()) installs all web applications included in the package.
Output folder
The folder that is zipped is determined as follows:
The BuildOutputFolder property, if specified in the web application project.
The dist folder for .esproj projects, or the wwwroot folder in the publish directory for other projects.
For example, to zip the build folder instead:
<PropertyGroup>
<DataMinerType>WebApplication</DataMinerType>
<BuildOutputFolder>$(MSBuildProjectDirectory)\build</BuildOutputFolder>
</PropertyGroup>
Note
Previously, web applications were deployed by placing the built website in the PackageContent/CompanionFiles folder of the package project and registering it with installerHelper.WebApplications.RegisterStaticApp(). This method is now deprecated. Use a web application project instead.
Installing web applications during installation
The Skyline.DataMiner.Utils.AppInstallerHelper NuGet package also allows you to install the web applications included in the package separately in the installation code of the package project:
var installerHelper = new AppInstallerHelper(Engine.SLNetRaw, context);
// Install all web applications included in the package.
installerHelper.WebApplications.InstallWebApplications();
// Or install specific web applications.
foreach (var webApplication in installerHelper.WebApplications.GetWebApplicationsToInstall())
{
installerHelper.WebApplications.InstallWebApplication(webApplication);
}