Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trigger: none
parameters:
# Matrix with target build platforms.
# x86 versions are not supported by Native AOT.
# Use net9.0 as the latest stable version.
# Use net10.0 as the latest stable version.
- name: buildMatrix
type: object
default:
Expand Down Expand Up @@ -81,27 +81,55 @@ parameters:
os: windows
TargetRuntime: win-x64
DotNetVersion: net9.0
- Name: win_x64_net100
Pool:
name: Azure-Pipelines-1ESPT-ExDShared
vmImage: windows-latest
os: windows
TargetRuntime: win-x64
DotNetVersion: net10.0
- Name: osx_x64_net90
Pool:
name: Azure Pipelines
vmImage: macos-14
os: macOS
TargetRuntime: osx-x64
DotNetVersion: net9.0
- Name: osx_x64_net100
Pool:
name: Azure Pipelines
vmImage: macos-14
os: macOS
TargetRuntime: osx-x64
DotNetVersion: net10.0
- Name: osx_arm64_net90
Pool:
name: Azure Pipelines
vmImage: macos-14-arm64
os: macOS
TargetRuntime: osx-arm64
DotNetVersion: net9.0
- Name: osx_arm64_net100
Pool:
name: Azure Pipelines
vmImage: macos-14-arm64
os: macOS
TargetRuntime: osx-arm64
DotNetVersion: net10.0
- Name: linux_x64_net90
Pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
TargetRuntime: linux-x64
DotNetVersion: net9.0
- Name: linux_x64_net100
Pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
TargetRuntime: linux-x64
DotNetVersion: net10.0

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

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

Expand Down Expand Up @@ -243,6 +271,13 @@ extends:
packageType: sdk
version: 8.0.x

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

- task: UseDotNet@2
displayName: Install .NET SDK using global.json
inputs:
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ jobs:
strategy:
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
dotnet-version: [ net472, net8.0, net9.0]
dotnet-version: [ net472, net8.0, net9.0, net10.0]
node-version: [ 18.x, 22.x ]
configuration: [ Release ]
exclude:
# Exclude Node 18.x on .NET < 9, to thin the matrix.
# Exclude Node 18.x on .NET < 10, to thin the matrix.
- dotnet-version: net8.0
node-version: 18.x
- dotnet-version: net9.0
node-version: 18.x
- dotnet-version: net472
node-version: 18.x
# Exclude .NET 4.x on non-Windows OS.
Expand Down Expand Up @@ -46,6 +48,11 @@ jobs:
with:
dotnet-version: 9.0.x

- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

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

- name: Upload build artifacts
if: matrix.dotnet-version == 'net9.0' && matrix.node-version == '22.x'
if: matrix.dotnet-version == 'net10.0' && matrix.node-version == '22.x'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.configuration }}-packages
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ jobs:
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

- name: Setup .NET 9
- name: Setup .NET 10
if: matrix.language == 'csharp'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x

- name: Build C#
if: matrix.language == 'csharp'
run: dotnet build -f:net9.0 -p:Configuration=Debug -p:NBGV_GitEngine=Disabled
# Just build the .NET 9 target framework; other targets would be redundant for CodeQL.
run: dotnet build -f:net10.0 -p:Configuration=Debug -p:NBGV_GitEngine=Disabled
# Just build the .NET 10 target framework; other targets would be redundant for CodeQL.
# Disable git-versioning to prevent the shallow clone from causing build errors.

- name: Perform CodeQL Analysis
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
- name: Setup Pages
uses: actions/configure-pages@v4

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ jobs:
strategy:
matrix: # This must be kept in sync with the PR build matrix.
os: [ windows-latest, macos-latest, ubuntu-latest ]
dotnet-version: [ net472, net8.0, net9.0]
dotnet-version: [ net472, net8.0, net9.0, net10.0]
node-version: [ 18.x, 22.x ]
configuration: [ Release ]
exclude:
# Exclude Node 18.x on .NET < 9, to thin the matrix.
# Exclude Node 18.x on .NET < 10, to thin the matrix.
- dotnet-version: net8.0
node-version: 18.x
- dotnet-version: net9.0
node-version: 18.x
- dotnet-version: net472
node-version: 18.x
# Exclude .NET 4.x on non-Windows OS.
Expand Down
5 changes: 2 additions & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# DO NOT SPECIFY AUTHENTICATION CREDENTIALS IN THIS FILE.
# It should only be used to configure NPM registry sources.

# Use ADO public NPM registry to be complient
# Use ADO public NPM registry to be compliant
# Additional registries should be added as upstreams instead of being added here.

registry=https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/npm/registry/
always-auth=true
Comment thread
vmoroz marked this conversation as resolved.
registry=https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/npm/registry/
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"-c",
"Release",
"-f",
"net9.0",
"net10.0",
"--",
"--filter",
"*.NonAot.*"
Expand Down
2 changes: 1 addition & 1 deletion README-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dotnet pack
```
This produces both nuget and npm packages (for the current platform only) in the `out/pkg`
directory. It uses `Debug` configuration by default, which is slower but allows for
[debugging](#debugging). Append `-c Relase` to change the configuration.
[debugging](#debugging). Append `-c Release` to change the configuration.

## Test
```bash
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 net9.0 --filter *
dotnet run -c Release -f net10.0 --filter *
```

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

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

### List benchmarks
```
dotnet run -c Release -f net9.0 --list flat
dotnet run -c Release -f net10.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 @@ -43,7 +43,7 @@ The `node-api-dotnet-generator` npm package is a standalone command-line tool th
| Parameter | Alias | Description |
|---------------|-------|-------------|
| `--asssembly` | `-a` | Required path to the assembly file for which type definitions are to be generated.
| `--framework` | `-f` | Target framework moniker of system assembly dependencies, e.g. `net8.0`. Defaults to the .NET runtime version used when invoking the tool (currently .NET 8).
| `--framework` | `-f` | Target framework moniker of system assembly dependencies, e.g. `net10.0`. Defaults to the .NET runtime version used when invoking the tool (currently .NET 10).
| `--pack` | `-p` | Application targeting pack(s) to check when resolving system assembly dependencies. Defaults to `Microsoft.NETCore.App`. May be specified more than once. Add the `Microsoft.AspNetCore.App` targeting pack for an ASP.NET app, or `Microsoft.WindowsDesktop.App` for a Windows desktop app.
| `--reference` | `-r` | Path to an assembly that is referenced by the primary assembly. System assemblies are located automatically via the targeting packs and do not need to be specified separately. All other referenced assemblies must be provided. May be specified more than once.
| `--typedefs` | `-t` | Required path to output generated type definitions (`.d.ts`) file.
Expand Down
2 changes: 1 addition & 1 deletion docs/scenarios/js-dotnet-dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ For examples of this scenario, see one of these directories in the repo:
const dotnet = require('node-api-dotnet/net8.0');
```
:::
Currently the supported target frameworks are `net472`, `net8.0`, and `net9.0`.
Currently the supported target frameworks are `net472`, `net8.0`, `net9.0`, and `net10.0`.

4. Load one or more .NET packages using the generated `.js` files:
::: code-group
Expand Down
2 changes: 1 addition & 1 deletion docs/scenarios/js-dotnet-module.md
Original file line number Diff line number Diff line change
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`, `net8.0`, and `net9.0`.
Currently the supported target frameworks are `net472`, `net8.0`, `net9.0`, and `net10.0`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says that we support net9.0, but I see it being removed from the build matrix in the pipelines.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where in the build matrix that net9.0 was removed? Could you point out the file. There're a few places where we build the project with the latest framework, so I replaced .net 9 with .net 10. But other than those, I just added the new net10 to the build matrix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am referring to the publish.yml file. This ADO pipeline is responsible for creating the NuGet files.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am OK with that. There are probably few if any teams on .NET 9 who haven't already migrated to .NET 10. So it's OK to exclude 9 from the build matrix until support is dropped. (Official support for .NET 9 ends Nov 2026.) Anyway it is very unlikely that there would be any bug on .NET 9 that doesn't also repro on either 8 or 10.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it looks like in publish.yml both .NET 9 and 10 are published for Windows win_x64 platform, but only .NET 10 for linux & mac platforms. That's odd.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I am for consistency. If we want to drop 9.0 then it is fine. Let's just make it consistent through the code. Though, I would rather keep 9.0 at least until the end of the official .Net support.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vmoroz @jasongin With the current code, I saw that on windows we built net8, net9 and net47, but only built the latest net9 on macos and linux. So I thought for those two platforms, I just needed to replace net9 and net10.

I'm happy to add net9 back for macos and linux. Let me know what you think? What's the reason we don't build net8 on those platforms?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added .net9 back for macos and linux


7. Load your .NET module assembly from its path using the `dotnet.require()` function:
```JavaScript
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": "9.0.100",
"version": "10.0.100",
"allowPrerelease": true,
"rollForward": "latestFeature"
}
Expand Down
2 changes: 1 addition & 1 deletion src/NodeApi.Generator/NodeApi.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<SelfContained>false</SelfContained>
<RollForward>major</RollForward><!-- Enable running on .NET 6 or any later major version. -->
<RollForward>major</RollForward><!-- Enable running on .NET 8 or any later major version. -->
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/NodeApi.Generator/NodeApi.Generator.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Resolves NodeApi source-generator (analyzer) assemblies.
The recommended practice is to build analyzers targeting only .NET Standard 2.0, and place them in a special "analyzers" directory
in the package where they are found automatically. But this package contains separate targets for .NET Standard 2.0, .NET Framework 4.x,
and .NET 6.0 (and later) in the "lib" directory. This task chooses the correct target based on the currnet MSBuild process's .NET version
and .NET 8.0 (and later) in the "lib" directory. This task chooses the correct target based on the currnet MSBuild process's .NET version
(NOT the current target framework), and adds the assemblies to the Analyzer item group.
-->
<Target Name="ResolveNodeApiAnalyzer" AfterTargets="ResolvePackageDependenciesForBuild">
Expand Down
7 changes: 2 additions & 5 deletions src/NodeApi/Runtime/PooledBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ private PooledBuffer(ArrayPool<byte> pool, int length, int bufferMinimumLength)

public void Dispose()
Comment thread
vmoroz marked this conversation as resolved.
{
if (_pool != null)
{
_pool.Return(Buffer!);
_pool = null;
}
_pool?.Return(Buffer!);
_pool = null;
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/node-api-dotnet/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* const dotnet = require('node-api-dotnet/net8.0');
* ```
* :::
* Currently the supported target frameworks are `net472`, `net8.0`, and `net9.0`.
* Currently the supported target frameworks are `net472`, `net8.0`, `net9.0`, and `net10.0`.
* @module node-api-dotnet
*/
declare module 'node-api-dotnet' {
Expand Down
36 changes: 28 additions & 8 deletions test/TestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ public static void BuildProject(
{
if (GetNoBuild()) return;

string workingDirectory = Path.GetDirectoryName(logFilePath)!;
string workingDirectory = Path.GetDirectoryName(projectFilePath)!;
if (target != "Publish")
{
WriteCurrentFrameworkGlobalJson(workingDirectory);
WriteCurrentFrameworkGlobalJson(workingDirectory, projectFilePath);
}

using StreamWriter logWriter = new(File.Open(
Expand Down Expand Up @@ -213,10 +213,21 @@ public static void BuildProject(
WorkingDirectory = workingDirectory,
};

if (Environment.Version.Major == 8)
// Prevent nested dotnet invocations from inheriting the current host path from the
// parent dotnet process, which can cause host/runtime mismatches when SDK selection
// rolls forward to a newer major version.
if (Environment.Version.Major != 4)
{
// Prevent the launched build from using the same MSBuild SDK that was used to run the test.
startInfo.Environment["MSBuildSDKsPath"] = "";
startInfo.Environment.Remove("MSBuildSDKsPath");
startInfo.Environment.Remove("DOTNET_HOST_PATH");
startInfo.Environment.Remove("DOTNET_ROOT");
startInfo.Environment.Remove("DOTNET_ROOT(x86)");
startInfo.Environment.Remove("DOTNET_ROOT_X86");
startInfo.Environment.Remove("DOTNET_ROOT(x64)");
startInfo.Environment.Remove("DOTNET_ROOT_X64");
startInfo.Environment.Remove("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR");
startInfo.Environment.Remove("DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR");
startInfo.Environment.Remove("DOTNET_MSBUILD_SDK_RESOLVER_SDKS_VER");
}

logWriter.WriteLine($"dotnet {startInfo.Arguments}");
Expand All @@ -241,7 +252,9 @@ public static void BuildProject(
}
}

private static void WriteCurrentFrameworkGlobalJson(string workingDirectory)
private static void WriteCurrentFrameworkGlobalJson(
string workingDirectory,
string projectFilePath)
{
Version frameworkVersion = Environment.Version;
if (frameworkVersion.Major == 4)
Expand Down Expand Up @@ -272,8 +285,15 @@ private static void WriteCurrentFrameworkGlobalJson(string workingDirectory)
}
}
""";
string globalJsonFilePath = Path.Combine(workingDirectory, "global.json");
File.WriteAllText(globalJsonFilePath, globalJson);

// SDK resolution for `dotnet build <project-path>` walks from the project directory,
// so write global.json both near logs and next to the generated project file.
string workingDirGlobalJsonFilePath = Path.Combine(workingDirectory, "global.json");
File.WriteAllText(workingDirGlobalJsonFilePath, globalJson);

string projectDirectory = Path.GetDirectoryName(projectFilePath)!;
string projectDirGlobalJsonFilePath = Path.Combine(projectDirectory, "global.json");
File.WriteAllText(projectDirGlobalJsonFilePath, globalJson);
}

public static void RunNodeTestCase(
Expand Down
Loading