Skip to content
Merged
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
16 changes: 13 additions & 3 deletions docs/core/tutorials/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,23 +342,33 @@ You may wish to write a library which depends on a native `.dll` file. If you'r
For the first option, you'll need to include the following in your `project.json` file:

1. Setting `allowUnsafe` to `true` in a `buildOptions` section.
2. Specifying the path to the native `.dll`(s) with a [Runtime Identifier (RID)](../rid-catalog.md) under `files` in the `packOptions` section.
2. Specifying a [Runtime Identifier (RID)](../rid-catalog.md) in a `runtimes` section.
3. Specifying the path to the native `.dll` file(s) that you are referencing.

If you're distributing your library as a package, it's recommended that you place the `.dll` file at the root level of your project. Here's an example `project.json` for a native `.dll` file that runs on Windows x64:
Here's an example `project.json` for a native `.dll` file in the root directory of the project which runs on Windows:

```json
{
"buildOptions":{
"allowUnsafe":true
},
"runtimes":{
"win10-x64":{}
},
"packOptions":{
"files":{
"runtimes/win7-x64/native/":"native-lib.dll"
"mappings":{
"runtimes/win10-x64/native":{
"includeFiles":[ "native-lib.dll"]
}
}
}
}
}
```

If you're distributing your library as a package, it's recommended that you place the `.dll` file at the root level of your project.

For the second option, you'll need to build a NuGet package out of your `.dll` file(s), host on a NuGet or MyGet feed, and depend on it directly. You'll still need to set `allowUnsafe` to `true` in the `buildOptions` section of your `project.json`. Here's an example (assuming `MyNativeLib` is a Nuget package at version `1.2.0`):

```json
Expand Down