Create test project

Use the still open shell to create the test project.

1.Create the test project.

Example:

mkdir NetcoreAppTestProject

cd NetcoreAppTestProject

@echo create new Project from console template

dotnet new console

@echo build Project

dotnet build

@echo run Project

dotnet run

2.Add the NuGet.config file to the development project directory.

information_weiss_klein26

This must be copied to the directory in which also the project definition file .csproj of the customer project locates.

3.Create package reference to WibuCmNet in the project file.

Command line example:

dotnet add NetcoreAppTestProject.csproj package Wibu.CodeMeter.WibuCmNET --framework netcoreapp2.0

In the .csproj file the following entry was supplemented. Example:

<ItemGroup>
<PackageReference Include="Wibu.CodeMeter.WibuCmNET" Version="6.60.2847.201" />
</ItemGroup>

4.Edit the test project and add WibuCmNet-specific code:

using System;
using CodeMeter;
 
namespace NetcoreAppTestProject
{
  class Program
   {
      static void Main(string[] args)
       {
         Console.WriteLine("Hello World!");                      
     
         Api cmApi = new Api();
 
         CmAccess cmAcc = new CmAccess();
 
         cmAcc.Ctrl |= CmAccess.Option.NoUserLimit;
 
         HCMSysEntry hcmse = cmApi.CmAccess(CmAccessOption.Local, cmAcc);
 
         CmBoxInfo[] cmBoxInfo;
             
         cmBoxInfo = cmApi.CmGetBoxes(hcmse, CodeMeter.CmGetBoxesOption.AllPorts);
         Console.WriteLine("API found {0} boxes", cmBoxInfo.Length);
        foreach (CmBoxInfo info in cmBoxInfo)
         {        
           Console.WriteLine("{0}-{1} {2}.{3}", info.BoxMask, info.SerialNumber, info.MajorVersion, info.MinorVersion);
         }
 
        bool res = cmApi.CmRelease(hcmse);
       }
   }
}

On building the package is sought in the previously defined package cache and the references are solved.

@echo run restore to get all dll references from the nuget packages
dotnet restore
 
@echo build Project
dotnet build
 
@echo run Project from source
dotnet run --framework netcoreapp2.0

5.Publish the solution after release.

Command line example:

dotnet publish --configuration Release --framework netcoreapp2.0 -property:Platform="AnyCPU"

In the bin/Release/netcoreapp2.0/publish directory an executable application is created to be started using the dotnet command.