Unverified Commit d57d5372 authored by David McFarland's avatar David McFarland Committed by GitHub
Browse files

Merge pull request #304780 from corngood/dotnet-self-contained-fix

dotnet: fix --self-contained builds
parents d771229e 57d6e5bd
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
, stdenv
, buildDotnetModule
, fetchFromGitHub
, autoPatchelfHook
, fontconfig
, xorg
, libglvnd
@@ -27,7 +26,6 @@ buildDotnetModule rec {
  dotnetFlags = [ "-p:Runtimeidentifier=linux-x64" ];

  nativeBuildInputs = [
    autoPatchelfHook
    copyDesktopItems
    graphicsmagick
  ];
+0 −2
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@
  fetchFromGitHub,
  buildDotnetModule,
  dotnetCorePackages,
  autoPatchelfHook,
  zlib,
  openssl,
}:
@@ -25,7 +24,6 @@ buildDotnetModule rec {
  dotnet-sdk = dotnetCorePackages.sdk_7_0;
  dotnet-runtime = dotnetCorePackages.aspnetcore_7_0;

  nativeBuildInputs = [autoPatchelfHook];
  buildInputs = [stdenv.cc.cc.lib zlib];

  runtimeDeps = [openssl zlib];
+1 −3
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
, makeDesktopItem
, copyDesktopItems
, icoutils
, autoPatchelfHook
, bintools
, fixDarwinDylibNames
, autoSignDarwinBinariesHook
@@ -40,8 +39,7 @@ buildDotnetModule rec {
  nativeBuildInputs = [
    copyDesktopItems
    icoutils
  ] ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [ bintools fixDarwinDylibNames ]
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ bintools fixDarwinDylibNames ]
    ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ autoSignDarwinBinariesHook ];

  buildInputs = [
+7 −4
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ assert if type == "sdk" then packages != null else true;
, writeShellScript
, mkNugetDeps
, callPackage
, dotnetCorePackages
}:

let
@@ -44,6 +45,8 @@ let

  mkCommon = callPackage ./common.nix {};

  targetRid = dotnetCorePackages.systemToDotnetRid stdenv.targetPlatform.system;

in
mkCommon type rec {
  inherit pname version;
@@ -88,21 +91,21 @@ mkCommon type rec {

  # Tell autoPatchelf about runtime dependencies.
  # (postFixup phase is run before autoPatchelfHook.)
  postFixup = lib.optionalString stdenv.isLinux ''
  postFixup = lib.optionalString stdenv.targetPlatform.isLinux ''
    patchelf \
      --add-needed libicui18n.so \
      --add-needed libicuuc.so \
      $out/shared/Microsoft.NETCore.App/*/libcoreclr.so \
      $out/shared/Microsoft.NETCore.App/*/*System.Globalization.Native.so \
      $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
      $out/packs/Microsoft.NETCore.App.Host.${targetRid}/*/runtimes/${targetRid}/native/*host
    patchelf \
      --add-needed libgssapi_krb5.so \
      $out/shared/Microsoft.NETCore.App/*/*System.Net.Security.Native.so \
      $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
      $out/packs/Microsoft.NETCore.App.Host.${targetRid}/*/runtimes/${targetRid}/native/*host
    patchelf \
      --add-needed libssl.so \
      $out/shared/Microsoft.NETCore.App/*/*System.Security.Cryptography.Native.OpenSsl.so \
      $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
      $out/packs/Microsoft.NETCore.App.Host.${targetRid}/*/runtimes/${targetRid}/native/*host
  '';

  passthru = {
+13 −2
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@
          '' + build);
        in
          if run == null
            then build
            then built
          else
            runCommand "${built.name}-run" { src = built; nativeBuildInputs = runInputs; } (
              lib.optionalString (runtime != null) ''
@@ -71,8 +71,10 @@
                export DOTNET_ROOT=${runtime}
              '' + run);

      # Setting LANG to something other than 'C' forces the runtime to search
      # for ICU, which will be required in most user environments.
      checkConsoleOutput = command: ''
        output="$(${command})"
        output="$(LANG=C.UTF-8 ${command})"
        # yes, older SDKs omit the comma
        [[ "$output" =~ Hello,?\ World! ]] && touch "$out"
      '';
@@ -98,6 +100,15 @@
        run = checkConsoleOutput "$src/test";
      };

      self-contained = mkDotnetTest {
        name = "self-contained";
        template = "console";
        usePackageSource = true;
        build = "dotnet publish --use-current-runtime --sc -o $out";
        runtime = null;
        run = checkConsoleOutput "$src/test";
      };

      single-file = mkDotnetTest {
        name = "single-file";
        template = "console";
Loading