Skip to content

Modernize NuGet package: Native AOT, trimming, and .NET Standard 2.0 cross-platform support - #145

Closed
jas88 wants to merge 1 commit into
mainfrom
feature/netstandard20-support
Closed

jas88 wants to merge 1 commit into
mainfrom
feature/netstandard20-support

Conversation

@jas88

@jas88 jas88 commented Oct 26, 2025

Copy link
Copy Markdown
Owner

This comprehensive update modernizes the LibArchive.Net package to follow current .NET best practices and fully resolves issue #69 (.NET Standard support).

Summary of Changes

Native Library Structure

  • ✅ Move libraries to proper runtimes/{rid}/native/ structure per Microsoft guidelines
  • ✅ Rename osx-any64 → osx-x64 (valid RID)
  • ✅ Add osx-arm64 for Apple Silicon support
  • ✅ Add linux-musl-x64 for Alpine Linux support
  • ✅ Update all build scripts to output to correct locations

P/Invoke Modernization

  • ✅ Add LibraryImport for .NET 7+ (source-generated, AOT-friendly)
  • ✅ Keep DllImport for older frameworks (.NET Standard 2.0, .NET 6.0)
  • ✅ Remove unnecessary custom import resolver for .NET 6+
  • ✅ Rely on automatic runtime resolution from runtimes/{rid}/native/

.NET Standard 2.0 Cross-Platform Support (Fixes #69)

  • ✅ Add dlopen() support for Linux/Mono
  • ✅ Add dlopen() support for macOS/Mono
  • ✅ Multi-version libdl compatibility (libdl.so.2, libdl.so)
  • ✅ Windows support via LoadLibrary() (already working)
  • ✅ Full cross-platform support: Windows/.NET Framework, Linux/Mono, macOS/Mono

AOT and Trimming Support

  • ✅ Add IsAotCompatible=true for .NET 6+
  • ✅ Add IsTrimmable=true for .NET 6+
  • ✅ Enable trim analyzer for build-time validation
  • ✅ Enable AOT analyzer for .NET 8+
  • ✅ Update package tags: AOT, NativeAOT, Trimming

CI/CD Improvements

  • ✅ Fix build.yml to use new runtimes/{rid}/native/ paths
  • ✅ Add Mono test job for .NET Standard 2.0 validation
  • ✅ Multi-target test project: net9.0 and net462
  • ✅ Comprehensive testing across all supported frameworks

Platform Support Matrix

Framework Platform Support
netstandard2.0 Windows/.NET Framework 4.6.1+ ✅ Full
netstandard2.0 Linux/Mono ✅ Full
netstandard2.0 macOS/Mono ✅ Full
net6.0 All platforms ✅ Automatic loading
net8.0 All platforms ✅ LibraryImport + AOT

Testing

CI will now run:

  • macOS build (universal binary)
  • Linux build
  • .NET 9.0 tests
  • NEW: Mono tests (.NET Standard 2.0 validation on Linux)

Closes #69

…cross-platform support

This comprehensive update modernizes the LibArchive.Net package to follow current
.NET best practices and fully resolves issue #69 (.NET Standard support).

## Native Library Structure
- Move libraries to proper runtimes/{rid}/native/ structure per Microsoft guidelines
- Rename osx-any64 → osx-x64 (valid RID)
- Add osx-arm64 for Apple Silicon support
- Add linux-musl-x64 for Alpine Linux support
- Update all build scripts to output to correct locations

## P/Invoke Modernization
- Add LibraryImport for .NET 7+ (source-generated, AOT-friendly)
- Keep DllImport for older frameworks (.NET Standard 2.0, .NET 6.0)
- Remove unnecessary custom import resolver for .NET 6+
- Rely on automatic runtime resolution from runtimes/{rid}/native/

## .NET Standard 2.0 Cross-Platform Support (Fixes #69)
- Add dlopen() support for Linux/Mono
- Add dlopen() support for macOS/Mono
- Multi-version libdl compatibility (libdl.so.2, libdl.so)
- Windows support via LoadLibrary() (already working)
- Full cross-platform support: Windows/.NET Framework, Linux/Mono, macOS/Mono

## AOT and Trimming Support
- Add IsAotCompatible=true for .NET 6+
- Add IsTrimmable=true for .NET 6+
- Enable trim analyzer for build-time validation
- Enable AOT analyzer for .NET 8+
- Update package tags: AOT, NativeAOT, Trimming

## CI/CD Improvements
- Fix build.yml to use new runtimes/{rid}/native/ paths
- Add Mono test job for .NET Standard 2.0 validation
- Multi-target test project: net9.0 and net462
- Comprehensive testing across all supported frameworks

## Platform Support Matrix
- netstandard2.0: Windows/.NET Framework 4.6.1+, Linux/Mono, macOS/Mono
- net6.0: All platforms with automatic library loading
- net8.0: All platforms with LibraryImport and full AOT support

Closes #69
@jas88

jas88 commented Oct 26, 2025

Copy link
Copy Markdown
Owner Author

Duplicate PR - closing in favor of existing PR for this branch

@jas88 jas88 closed this Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET Standard support?

1 participant