Skip to content

Commit

Permalink
Add .NET 9 support, remove .NET 6
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin committed Jan 22, 2025
1 parent 50061dd commit 2d04d92
Show file tree
Hide file tree
Showing 35 changed files with 111 additions and 104 deletions.
30 changes: 15 additions & 15 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trigger: none
parameters:
# Matrix with target build platforms.
# x86 versions are not supported by Native AOT.
# Use net8.0 as the latest stable version.
# Use net9.0 as the latest stable version.
- name: buildMatrix
type: object
default:
Expand Down Expand Up @@ -64,41 +64,41 @@ parameters:
os: windows
TargetRuntime: win-x64
DotNetVersion: net472
- Name: win_x64_net60
- Name: win_x64_net80
Pool:
name: Azure-Pipelines-1ESPT-ExDShared
vmImage: windows-latest
os: windows
TargetRuntime: win-x64
DotNetVersion: net6.0
- Name: win_x64_net80
DotNetVersion: net8.0
- Name: win_x64_net90
Pool:
name: Azure-Pipelines-1ESPT-ExDShared
vmImage: windows-latest
os: windows
TargetRuntime: win-x64
DotNetVersion: net8.0
- Name: osx_x64_net80
DotNetVersion: net9.0
- Name: osx_x64_net90
Pool:
name: Azure Pipelines
vmImage: macos-14
os: macOS
TargetRuntime: osx-x64
DotNetVersion: net8.0
- Name: osx_arm64_net80
DotNetVersion: net9.0
- Name: osx_arm64_net90
Pool:
name: Azure Pipelines
vmImage: macos-14-arm64
os: macOS
TargetRuntime: osx-arm64
DotNetVersion: net8.0
- Name: linux_x64_net80
DotNetVersion: net9.0
- Name: linux_x64_net90
Pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
TargetRuntime: linux-x64
DotNetVersion: net8.0
DotNetVersion: net9.0

resources:
repositories:
Expand Down Expand Up @@ -141,7 +141,7 @@ extends:
cancelTimeoutInMinutes: 45 # to allow more time to collect CodeQL debug info.

variables:
DotNetMoniker: net8.0
DotNetMoniker: net9.0
${{ if and( variables.DisableOsxArm64CodeQL, eq( MatrixEntry.TargetRuntime, 'osx-arm64' )) }}:
ONEES_ENFORCED_CODEQL_ENABLED: false

Expand Down Expand Up @@ -233,12 +233,12 @@ extends:
- checkout: self
displayName: Shallow git fetch

- ${{ if eq( MatrixEntry.DotNetVersion, 'net6.0' ) }}:
- ${{ if eq( MatrixEntry.DotNetVersion, 'net8.0' ) }}:
- task: UseDotNet@2
displayName: Install .Net 6.0.x
displayName: Install .Net 8.0.x
inputs:
packageType: sdk
version: 6.0.x
version: 8.0.x

- task: UseDotNet@2
displayName: Install .NET SDK using global.json
Expand Down
25 changes: 10 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ jobs:
strategy:
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
dotnet-version: [ net472, net6.0, net8.0]
node-version: [ 18.x, 20.x ]
dotnet-version: [ net472, net8.0, net9.0]
node-version: [ 18.x, 22.x ]
configuration: [ Release ]
exclude:
# Exclude Node 18.x on .NET < 8, to thin the matrix.
- dotnet-version: net6.0
# Exclude Node 18.x on .NET < 9, to thin the matrix.
- dotnet-version: net8.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
dotnet-version: net472
- os: ubuntu-latest
dotnet-version: net472

Expand All @@ -36,20 +36,15 @@ jobs:
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
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

# The .NET 8 SDK is required even when the build matrix targets other .NET versions.
- name: Setup .NET 8
- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
Expand All @@ -67,7 +62,7 @@ jobs:
# limit-access-to-actor: true

- name: Upload build artifacts
if: matrix.dotnet-version == 'net8.0' && matrix.node-version == '20.x'
if: matrix.dotnet-version == 'net9.0' && matrix.node-version == '22.x'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.configuration }}-packages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: npm
cache-dependency-path: './docs/package-lock.json'
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Setup Pages
uses: actions/configure-pages@v4

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ jobs:
strategy:
matrix: # This must be kept in sync with the PR build matrix.
os: [ windows-latest, macos-latest, ubuntu-latest ]
dotnet-version: [ net472, net6.0, net8.0]
node-version: [ 18.x, 20.x ]
dotnet-version: [ net472, net8.0, net9.0]
node-version: [ 18.x, 22.x ]
configuration: [ Release ]
exclude:
# Exclude Node 18.x on .NET < 8, to thin the matrix.
- dotnet-version: net6.0
# Exclude Node 18.x on .NET < 9, to thin the matrix.
- dotnet-version: net8.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
dotnet-version: net472
- os: ubuntu-latest
dotnet-version: net472

Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"-c",
"Release",
"-f",
"net8.0",
"net9.0",
"--",
"--filter",
"*.NonAot.*"
Expand All @@ -68,7 +68,7 @@
"-c",
"Release",
"-f",
"net8.0",
"net9.0",
"--",
"--filter",
"*.Aot.*"
Expand Down
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and ! $([MSBuild]::IsOsPlatform('Windows')) ">net8.0;net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and $([MSBuild]::IsOsPlatform('Windows')) ">net8.0;net6.0;netstandard2.0;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$(PublishAot)' == 'true' ">net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and ! $([MSBuild]::IsOsPlatform('Windows')) ">net9.0;net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and $([MSBuild]::IsOsPlatform('Windows')) ">net9.0;net8.0;netstandard2.0;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$(PublishAot)' == 'true' ">net9.0</TargetFrameworks>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
Expand Down
4 changes: 2 additions & 2 deletions bench/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<!-- The main purpose of this file is to prevent use of the root Directory.Build.props file,
because Benchmark.NET does not like the build output paths to be redirected. -->
<PropertyGroup>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and ! $([MSBuild]::IsOsPlatform('Windows')) ">net8.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and $([MSBuild]::IsOsPlatform('Windows')) ">net8.0;net6.0;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and ! $([MSBuild]::IsOsPlatform('Windows')) ">net9.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and $([MSBuild]::IsOsPlatform('Windows')) ">net9.0;net8.0;net472</TargetFrameworks>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<PackRelease>false</PackRelease>
Expand Down
10 changes: 5 additions & 5 deletions bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ though the "Dynamic" benchmarks are CLR-only.
### Run all benchmarks
```
dotnet run -c Release -f net8.0 --filter *
dotnet run -c Release -f net9.0 --filter *
```

### Run only CLR or only AOT benchmarks
```
dotnet run -c Release -f net8.0 --filter *clr.*
dotnet run -c Release -f net8.0 --filter *aot.*
dotnet run -c Release -f net9.0 --filter *clr.*
dotnet run -c Release -f net9.0 --filter *aot.*
```

### Run a specific benchmark
```
dotnet run -c Release -f net8.0 --filter *clr.CallDotnetFunction
dotnet run -c Release -f net9.0 --filter *clr.CallDotnetFunction
```

### List benchmarks
```
dotnet run -c Release -f net8.0 --list flat
dotnet run -c Release -f net9.0 --list flat
```
2 changes: 1 addition & 1 deletion docs/features/type-definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The easiest way to generate type definitions is to leverage the provided MSBuild
the `Microsoft.JavaScript.NodeApi.Generator` NuGet package:
```xml
<ItemGroup>
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.7.*-*" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.*-*" />
</ItemGroup>
```

Expand Down
10 changes: 5 additions & 5 deletions docs/scenarios/js-dotnet-dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For examples of this scenario, see one of these directories in the repo:
```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutDir>bin</OutDir>
<NodeApiAssemblyJSModuleType>commonjs</NodeApiAssemblyJSModuleType>// [!code highlight]
</PropertyGroup>
Expand Down Expand Up @@ -72,16 +72,16 @@ For examples of this scenario, see one of these directories in the repo:
A `.js` suffix is required when using ES modules, optional with CommonJS.
::: code-group
```JavaScript [ES (TS or JS)]
import dotnet from 'node-api-dotnet/net6.0.js';
import dotnet from 'node-api-dotnet/net8.0.js';
```
```TypeScript [CommonJS (TS)]
import * as dotnet from 'node-api-dotnet/net6.0';
import * as dotnet from 'node-api-dotnet/net8.0';
```
```JavaScript [CommonJS (JS)]
const dotnet = require('node-api-dotnet/net6.0');
const dotnet = require('node-api-dotnet/net8.0');
```
:::
Currently the supported target frameworks are `net472`, `net6.0`, and `net8.0`.
Currently the supported target frameworks are `net472`, `net8.0`, and `net9.0`.

4. Load one or more .NET packages using the generated `.js` files:
::: code-group
Expand Down
10 changes: 5 additions & 5 deletions docs/scenarios/js-dotnet-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
For a minimal example of this scenario, see
[/examples/dotnet-module/](https://github.com/microsoft/node-api-dotnet/blob/main/examples/dotnet-module/).

1. Create a .NET Class library project that targets .NET 6 or later. (.NET 8 for AOT.)
1. Create a .NET Class library project that targets .NET 8 or later.
```shell
mkdir ExampleModule
cd ExampleModule
dotnet new classlib --framework net6.0
dotnet new classlib --framework net8.0
```

2. Add a reference to the `Microsoft.JavaScript.NodeApi` and
Expand All @@ -20,8 +20,8 @@ For a minimal example of this scenario, see
Afterward you should have the two references in your project file:
```xml
<ItemGroup>
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.7.*-*" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.7.*-*" />
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.9.*-*" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.*-*" />
</ItemGroup>
```

Expand Down Expand Up @@ -86,7 +86,7 @@ For a minimal example of this scenario, see
const dotnet = require('node-api-dotnet/net8.0');
```
:::
Currently the supported target frameworks are `net472`, `net6.0`, and `net8.0`.
Currently the supported target frameworks are `net472`, `net8.0`, and `net9.0`.
7. Load your .NET module assembly from its path using the `dotnet.require()` function:
```JavaScript
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/build-dotnet-api-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fs = require('node:fs');
const path = require('node:path');

const assemblyNamePrefix = 'Microsoft.JavaScript.';
const docsTargetFramework = 'net6.0';
const docsTargetFramework = 'net8.0';
const docsConfiguration = 'Release';
const ridPlatform =
process.platform === 'win32' ? 'win' :
Expand Down
2 changes: 1 addition & 1 deletion examples/semantic-kernel/semantic-kernel.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RestorePackagesPath>$(MSBuildThisFileDirectory)/pkg</RestorePackagesPath>
<OutDir>bin</OutDir>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/wpf/WpfExample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<RestorePackagesPath>$(MSBuildThisFileDirectory)/pkg</RestorePackagesPath>
<OutDir>bin</OutDir>
<UseWPF>true</UseWPF>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.100",
"allowPrerelease": true,
"rollForward": "latestFeature"
}
Expand Down
2 changes: 1 addition & 1 deletion src/NodeApi.DotNetHost/JSMarshaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ Expression TupleItem(int index) => InlineOrInvoke(
MethodInfo asDouble = typeof(JSValue).GetExplicitConversion(
typeof(JSValue), typeof(double));
MethodInfo toTimeSpan = typeof(TimeSpan).GetStaticMethod(
nameof(TimeSpan.FromMilliseconds));
nameof(TimeSpan.FromMilliseconds), new[] { typeof(double) });
statements = new[]
{
Expression.Call(toTimeSpan, Expression.Call(asDouble, valueParameter)),
Expand Down
2 changes: 1 addition & 1 deletion src/NodeApi.DotNetHost/NodeApi.DotNetHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
It's necessary to use <Exec/> here rather than a recursive <MSBuild/> task because
PublishAot modifies properties/targets which would not be re-computed by the task.
-->
<Exec Command="dotnet publish $(MSBuildThisFileDirectory)..\NodeApi\NodeApi.csproj -c $(Configuration) -f net8.0 -p:PublishAot=true" />
<Exec Command="dotnet publish $(MSBuildThisFileDirectory)..\NodeApi\NodeApi.csproj -c $(Configuration) -f net9.0 --self-contained -p:PublishAot=true" />
</Target>

<Target Name="NpmPack"
Expand Down
Loading

0 comments on commit 2d04d92

Please sign in to comment.