Skip to content

sec/dotnet-core-freebsd-source-build

Repository files navigation

Build .NET Core 9 under FreeBSD

2025

Hacky way for native build, tested with v9.preview.7, old, use ports


  • aspnet runtime nuget with 6.0.32
  • app host both runtime and aspnet with 6.0.32
  • I use some old v6 versions and repack them with new version, scripts in repo, maybe there's better way for that
  • eng/Versions.props, line 217 with MicrosoftDotNetILCompilerVersion, put 9.0.0-preview.7.24405.7 or the one you have with SDK
  • add nuget source for SDK nuget's your compile with
  • adjust global.json versions to SDK version
  • for runtime, app host error could happen - this need sed linux-arch to freebsd-arc - ex. sed -i '' -e 's/linux-arm64/freebsd-arm64/g' runtime/.dotnet/sdk/9.0.100-preview.7.24407.12/Microsoft.NETCoreSdk.BundledVersions.props
  • add <NuGetAudit>false</NuGetAudit> into aspnetcore/Directory.Build.props
  • remove dnc/internal nuget feeds might also help

  • build runtime (ILC can/will fail due to missing symbols, copy from crossbuild, but final SDK/nuget will also be broken)
  • build aspnet (do not build with node/npm installed)
  • build sdk

Old New News (2024)

  • We how have community made port under FreeBSD ports for x64/amd64 and aarch64
  • /usr/ports/lang/dotnet/make install or pkg install will get you up and running
  • to speed up port build, use install_tools.sh first, unless you like everything from source

Old news (out-dated, but still some valid points)

  • Just a collection of script and patches put up into one place, to help getting automated builds.
  • For other versions, check proper tag with that name (mostly out-dated and not updated).
  • For my private nuget feed, check dotnet-freebsd-nuget-feed

Usage

  1. Run as root install_tools.sh - make sure to mount all needed things (add them to /etc/fstab, then mount -a)
  2. init.sh
  3. build_runtime.sh - add -v d inside if it will fail with SEHExceptions...
  4. build_aspnetcore.sh
  5. build_installer.sh - this one can fail with downloaing some things, copy URL and try to manualy fetch it into installer/artifacts/obj/redist/Release/downloads/
  6. Check installer/artifacts/packages/Release/Shipping/ or
  7. gather_output.sh will create one archive with everything you should need on target system
  8. clean.sh if you want to save disk space after use

Extra info

  • some steps can fail, some patches can fail to apply, mostly due to numbers, this needs to be handed by hand, as I don't update all the patches with every release
  • sometime some step can fail, due to zombie dotnet processes left, simple killall -9 dotnet will do the trick
  • when building under jail, mlock is required

Requirments

  1. Working SDK for FreeBSD
  2. Tested under FreeBSD 13 and 14
  3. 8GB+ of RAM recommended (with 4GB I saw some parts crashing)
  4. To run SDK and/or apps pkg install libunwind icu libinotify should be enough on another box, maybe openssl too
  5. Under 14 also pkg install misc/compat13x might be needed if using builds directly

Support

Ready builds, credits, etc

About

Collection of script to build .NET Core under FreeBSD OS (with binary releases)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages