User:Carsme/.NET package guidelines

From ArchWiki
Arch package guidelines

32-bitCLRCMakeCrossDKMSEclipseElectronFontFree PascalGNOMEGoHaskellJavaKDEKernelLispMesonMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRustShellVCSWebWine

This document covers standards and guidelines on writing PKGBUILDs for .NET.

General guidelines

Package naming

Use dotnet-modulename if the package provides a program that is strongly coupled to the .NET ecosystem. For other applications, use only the program name.

Note: The package name should be entirely lowercase.

Building

TODO.

Sample PKGBUILD

pkgname=foo
pkgver=0.0.1
_commit=862708594aa0d8e292f33b355df25e7bacab6f55
pkgrel=1
pkgdesc="Some .NET program"
arch=(x86_64)
url="https://example.com/$pkgname"
license=(MIT)
_dotnet_version=8.0
depends=(
  "dotnet-runtime-$_dotnet_version"
  gcc-libs
  glibc
)
makedepends=(
  "dotnet-sdk-$_dotnet_version"
  git
)
source=("git+$url.git?signed#commit=$_commit")
sha256sums=('SKIP')
validpgpkeys=('1337deadbeef')

prepare() {
  cd "$pkgname"

  export NUGET_PACKAGES="$PWD/nuget"
  export DOTNET_NOLOGO=true
  export DOTNET_CLI_TELEMETRY_OPTOUT=true
  dotnet restore --locked-mode src/Some.Program.Cli
  dotnet restore --locked-mode src/Some.Program.Tests

  git remote set-url origin "$url"
}

build() {
  cd "$pkgname"

  export NUGET_PACKAGES="$PWD/nuget"
  export DOTNET_NOLOGO=true
  export DOTNET_CLI_TELEMETRY_OPTOUT=true
  dotnet publish \
    --no-restore \
    --framework "net$_dotnet_version" \
    --runtime linux-x64 \
    --no-self-contained \
    --configuration release \
    --output lib \
    src/Some.Program.Cli
}

check() {
  cd "$pkgname"

  export NUGET_PACKAGES="$PWD/nuget"
  export DOTNET_NOLOGO=true
  export DOTNET_CLI_TELEMETRY_OPTOUT=true
  dotnet test \
    --no-restore \
    --framework "net$_dotnet_version" \
    ./src/Some.Program.Tests
}

package() {
  cd "$pkgname"

  local pkgnum=${pkgver:0:1}

  install -dm755 "$pkgdir/usr/lib/$pkgname-$pkgnum"
  cp --archive -t "$pkgdir/usr/lib/$pkgname-$pkgnum" lib/*

  install -dm755 "$pkgdir/usr/bin"
  ln -s "/usr/lib/$pkgname-$pkgnum/$pkgname" "$pkgdir/usr/bin/$pkgname"
}

Example packages