Skip to content

Add Example for Loading .NET DLL in Node.js and Electron.js #462

Add Example for Loading .NET DLL in Node.js and Electron.js

Add Example for Loading .NET DLL in Node.js and Electron.js #462

Workflow file for this run

# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: PR Verification
on:
pull_request:
branches: [ "main" ]
workflow_dispatch: # Enable manually starting a build
jobs:
build:
strategy:
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
dotnet-version: [ net472, net6.0, net8.0]
node-version: [ 18.x, 20.x ]
configuration: [ Release ]
exclude:
# Exclude Node 18.x on .NET < 8, to thin the matrix.
- dotnet-version: net6.0
node-version: 18.x
- dotnet-version: net472
node-version: 18.x
# Exclude .NET 4.x on non-Windows OS.
- os: macos-latest
dotnet-version: net472
- os: ubuntu-latest
dotnet-version: net472
fail-fast: false # Don't cancel other jobs when one job fails
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Deep clone is required for versioning on git commit height
- name: Link libdl.so # Required by .NET 6
if: matrix.os == 'ubuntu-latest'
run: sudo ln -s /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libdl.so
- name: Setup .NET 6
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
# The .NET 8 SDK is required even when the build matrix targets other .NET versions.
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Build packages
id: pack
run: dotnet pack --configuration ${{ matrix.configuration }}
# Uncomment to enable an SSH session for debugging
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true
- name: Upload build artifacts
if: matrix.dotnet-version == 'net8.0' && matrix.node-version == '20.x'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.configuration }}-packages
path: |
out/pkg/*.*nupkg
out/pkg/*.tgz
- name: Test
if: steps.pack.conclusion == 'success' && !cancelled()
env:
TRACE_NODE_API_HOST: 1
run: >
dotnet test -f ${{ matrix.dotnet-version }}
--configuration ${{ matrix.configuration }}
--logger trx
--results-directory "out/test/${{matrix.dotnet-version}}-node${{matrix.node-version}}-${{matrix.configuration}}"
continue-on-error: true
- name: Upload test logs
# upload-artifact@v4 breaks the test reporter: https://github.com/dorny/test-reporter/issues/343
uses: actions/upload-artifact@v3
with:
name: test-logs-${{ matrix.os }}-${{matrix.dotnet-version}}-node${{matrix.node-version}}-${{matrix.configuration}}
path: |
out/obj/${{ matrix.configuration }}/**/*.log
out/obj/${{ matrix.configuration }}/**/*.rsp
out/test/**/*.trx
- name: Check formatting
if: ${{ !cancelled() }} # Run this step even when there are build failures but not when cancelled
run: dotnet format --no-restore --severity info --verbosity detailed --verify-no-changes