https://github.com/meiktranel/nxports
A platform agnostic tool to export .NET functions at build time.
https://github.com/meiktranel/nxports
dotnet msbuild pinvoke
Last synced: 5 months ago
JSON representation
A platform agnostic tool to export .NET functions at build time.
- Host: GitHub
- URL: https://github.com/meiktranel/nxports
- Owner: MeikTranel
- License: mit
- Created: 2019-03-09T20:51:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-09T21:18:51.000Z (almost 2 years ago)
- Last Synced: 2025-12-01T09:37:14.402Z (6 months ago)
- Topics: dotnet, msbuild, pinvoke
- Language: C#
- Size: 186 KB
- Stars: 46
- Watchers: 3
- Forks: 6
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# NXPorts
[](https://github.com/MeikTranel/NXPorts/actions)
[](https://www.nuget.org/packages/NXPorts/)
[](https://codecov.io/gh/MeikTranel/NXPorts)
A MSBuild-integrated library/tool to expose entrypoints in .NET assemblies to the platform invocation system or short `PInvoke`.
It allows you to build .NET libraries that can be called from any development platform that supports `PInvoke`, including **C++**, **C**, **Rust**, **Delphi**, **Python** and so on...
## Getting Started
To get started you only have to add the `NXPorts` package to your project. That's it. `NXPorts` will automatically generate exports as
part of your build now. Some samples are available [here](./samples).
### Prerequisites
This software itself will run on any system that supports developing .NET software - it does **not** have any dependencies on
`ildasm.exe`, `ilasm.exe` or any other windows-only libraries.
Keep in mind that `Reverse PInvoke` - calling PInvoke entrypoints **in .NET assemblies** - is only officially supported
in the .NET Framework. It may work in other runtimes as well, but your mileage may vary.
See [Compatibility Docs](./docs/Compatibility.md) for more info.
### Sample
The following code will result in an exported function named `SampleExportFunc`.
```CSharp
public static class Exports {
[DllExport(alias:"SampleExportFunc")]
public static double Add(double a, double b)
{
return a + b;
}
}
```
## Building from Source
To build packages by yourself all you have to do is the dotnet cli like this:
```shell
dotnet pack
```
This will restore, build and pack all available projects. Testing this project is just as simple:
```shell
dotnet test
```
## Releasing NXPorts
To start releasing a new NXPorts version you just have close the associated milestone.
GitHub actions will then generate a checklist issue with further guidance.
**Fundamentals**:
- We're releasing to ``production`` (as in NuGet Gallery) from `tagged` builds
- We're releasing ``canary`` builds from master to our canary feed (GPR)
## Contributing
I am more than happy to take in PRs.
Documentation regarding Marshalling, PE32 or PInvoke (especially on non-NETFX runtimes) counts
just as much as a valuable contribution as any other code PR.
To me writing issues is also just as valuable. I may not list every issue reporter in the release notes, but
especially during the initial development timeline knowing the shortcomings of the software is absolutely invaluable.
### Guidelines
* Please consider writing an issue first
* Please target PRs towards the `master` branch