Skip to content

Dyalog/nuget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet

A tool to help use NuGet packages from Dyalog APL.

This code is used by Cider to support NuGet packages as project dependencies. It requires Dyalog v19.0 and .NET 6.0 or later.

The code can also be used outside of Cider, but documentation is currently rudimentary, consisting only in the form of this README file and the example code in the Tests/ folder.

Introduction

The NuGet tool works by tapping into the "dotnet" command line tool to establish a folder as a .NET project, and use tools built in to .NET to load NuGet packages. It requires .NET 6.0 or later, and Dyalog APL must be configured to use the new .NET by setting DYALOG_NETCORE=1.

Using NuGet with Cider

Please refer to the Cider documentation for instructions. At the time this was written, the user command to set up a NuGet dependency was ]CIDER.AddNuGetDependencies.

Brief API documentation

NuGet.Setup projectdir

Makes the initial call to the dotnet command to create a .NET project in the named directory. This must be called first. Example:

      NuGet.Setup '/tmp/nuget-test'
Created project file "/tmp/nuget-test/nuget-test.csproj"

{pub}NuGet.Add projectdir packageid

Adds a NuGet package as a dependency of the project found in the named directory and (optionally) publishes the package. The package name can optionally be followed by a version number; if no version is provided the latest will be used. Example:

      NuGet.Add '/tmp/nuget-test' 'Clock/1.0.3'
Added/Updated:  Clock 

The optional left argument pubcan be used to control whether the package should be published (1, default) or not (0). When adding several packages, you can save time by not publishing during the individual Adds, but by using pub=0 and calling Publish afterwards.

NuGet.BinFolder projectdir

Returns the fully qualified path to the binary output directory for a .NET project.

The function prioritizes Debug builds if both Debug and Release folders exist. The target framework (e.g., net6.0, net8.0) is automatically appended to create the complete binary path.

⎕USING←NuGet.Using projectdir

Returns the ⎕USING setting that will make it possible to reference the entry points of the added packages. Example:

      ]box on
Was OFF
      NuGet.Using project_dir
┌────────────────────────────────────┬─────────────────────────────────────────┐
│,/tmp/nuget-test/published/Clock.dll│,/tmp/nuget-test/published/nuget-test.dll│
└────────────────────────────────────┴─────────────────────────────────────────┘

If you do not want to include the DLL which represents the empty C# executable that was created by the dotnet command, you can specify this as follows:

      '(includePrimary: 0)' NuGet.Using project_dir 
┌────────────────────────────────────┐
│,/tmp/nuget-test/published/Clock.dll│
└────────────────────────────────────┘

NuGet.Packages projectdir

Returns the current list of dependencies::

      NuGet.Packages project_dir
┌─────────────┐
│┌─────┬─────┐│
││Clock│1.0.3││
│└─────┴─────┘│
└─────────────┘

NuGet.Publish projectdir

Publishes the project and its dependencies to a /published folder within the project directory. This step is automatically performed when adding packages (unless disabled with pub=0 in Add), but can be called separately when needed.

NuGet.Version

Returns the current NuGet version number:

      NuGet.Version
0.2.0

Running the Tests

To run the tests in Dyalog version 19.0, you must:

  • Make sure you have installed .NET 6.0 or later and set the configuration parameter DYALOG_NETCORE=1 (this is the default under Linux and macOS but not under Windows)
  • Either load the Tatin package using ]TATIN.LoadPackages dyalog-nuget, followed by ]get https://github.com/dyalog/nuget/tree/main/APLSource/Tests, or
  • ]get https://github.com/dyalog/nuget/tree/main/APLSource -unpack, which will establish both NuGet and Tests in the workspace.

To get a list of runnable tests:

      Tests.test ''
The current test functions exist:
 test_clock  test_humanizer  test_htmlsanitizer  test_mailkit  test_parquet  test_selenium 

To run a test:

      Tests.test 'selenium'
Created project file "/tmp/nuget-test/nuget-test.csproj"
Added/Updated:  Selenium.WebDriver  Selenium.WebDriver.ChromeDriver 
Successfully loaded Dyalog - Home

Note that you cannot run more than one test per APL session, because once the DLL's are loaded by the interpreter, there is currently no way to unload them.

About

Tools to help use NuGet packages from Dyalog APL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages