summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/languages-frameworks/dotnet.section.md2
-rw-r--r--pkgs/build-support/build-dotnet-module/default.nix34
2 files changed, 19 insertions, 17 deletions
diff --git a/doc/languages-frameworks/dotnet.section.md b/doc/languages-frameworks/dotnet.section.md
index 88e1a0b2959..f7af28a1677 100644
--- a/doc/languages-frameworks/dotnet.section.md
+++ b/doc/languages-frameworks/dotnet.section.md
@@ -84,7 +84,7 @@ To package Dotnet applications, you can use `buildDotnetModule`. This has simila
      <ProjectReference Include="../foo/bar.fsproj" />
      <PackageReference Include="bar" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' "/>
   ```
-* `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`.
+* `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`. This gets done in the `preFixup` phase.
 * `runtimeDeps` is used to wrap libraries into `LD_LIBRARY_PATH`. This is how dotnet usually handles runtime dependencies.
 * `buildType` is used to change the type of build. Possible values are `Release`, `Debug`, etc. By default, this is set to `Release`.
 * `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used.
diff --git a/pkgs/build-support/build-dotnet-module/default.nix b/pkgs/build-support/build-dotnet-module/default.nix
index 0a5b17a4a36..49a61f4e5d6 100644
--- a/pkgs/build-support/build-dotnet-module/default.nix
+++ b/pkgs/build-support/build-dotnet-module/default.nix
@@ -224,7 +224,7 @@ let
           "''${dotnetInstallFlags[@]}"  \
           "''${dotnetFlags[@]}"
       done
-    '' + (lib.optionalString packNupkg ''
+    '' + lib.optionalString packNupkg ''
       for project in ''${projectFile[@]}; do
         dotnet pack "$project" \
           -p:ContinuousIntegrationBuild=true \
@@ -235,16 +235,24 @@ let
           "''${dotnetPackFlags[@]}"  \
           "''${dotnetFlags[@]}"
       done
-    '') + (if executables != null then ''
-      for executable in $executables; do
+    '' + ''
+      runHook postInstall
+    '';
+
+    preFixup = ''
+      _wrapDotnetProgram() {
+        makeWrapper "$1" "$out/bin/$(basename "$executable")" \
+          --set DOTNET_ROOT "${dotnet-runtime}" \
+          --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
+          "''${gappsWrapperArgs[@]}" \
+          "''${makeWrapperArgs[@]}"
+      }
+    '' + (if executables != null then ''
+      for executable in ''${executables[@]}; do
         execPath="$out/lib/${args.pname}/$executable"
 
         if [[ -f "$execPath" && -x "$execPath" ]]; then
-          makeWrapper "$execPath" "$out/bin/$(basename "$executable")" \
-            --set DOTNET_ROOT "${dotnet-runtime}" \
-            --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
-            "''${gappsWrapperArgs[@]}" \
-            "''${makeWrapperArgs[@]}"
+          _wrapDotnetProgram $execPath
         else
           echo "Specified binary \"$executable\" is either not an executable, or does not exist!"
           exit 1
@@ -253,16 +261,10 @@ let
     '' else ''
       for executable in $out/lib/${args.pname}/*; do
         if [[ -f "$executable" && -x "$executable" && "$executable" != *"dll"* ]]; then
-          makeWrapper "$executable" "$out/bin/$(basename "$executable")" \
-            --set DOTNET_ROOT "${dotnet-runtime}" \
-            --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
-            "''${gappsWrapperArgs[@]}" \
-            "''${makeWrapperArgs[@]}"
+          _wrapDotnetProgram $executable
         fi
       done
-    '') + ''
-      runHook postInstall
-    '';
+    '');
   });
 in
   package