13 nativeBuildInputs ? [ ],
15 xBuildFlags ? [ "/p:Configuration=Release" ],
16 outputFiles ? [ "bin/Release/*" ],
17 dllFiles ? [ "*.dll" ],
18 exeFiles ? [ "*.exe" ],
19 # Additional arguments to pass to the makeWrapper function, which wraps
21 makeWrapperArgs ? [ ],
25 arrayToShell = (a: toString (map (lib.escape (lib.stringToCharacters "\\ ';$`()|<>\t")) a));
28 inherit pname version;
35 ] ++ nativeBuildInputs;
40 [ -z "''${dontPlacateNuget-}" ] && placate-nuget.sh
41 [ -z "''${dontPlacatePaket-}" ] && placate-paket.sh
42 [ -z "''${dontPatchFSharpTargets-}" ] && patch-fsharp-targets.sh
50 echo Building dotNET packages...
52 # Probably needs to be moved to fsharp
53 if pkg-config FSharp.Core
55 export FSharpTargetsPath="$(dirname $(pkg-config FSharp.Core --variable=Libraries))/Microsoft.FSharp.Targets"
59 for xBuildFile in ${arrayToShell xBuildFiles} ''${xBuildFilesExtra}
62 xbuild ${arrayToShell xBuildFlags} ''${xBuildFlagsArray} $xBuildFile
65 [ -z "$ran" ] && xbuild ${arrayToShell xBuildFlags} ''${xBuildFlagsArray}
75 target="$out/lib/dotnet/${pname}"
78 cp -rv ${arrayToShell outputFiles} "''${outputFilesArray[@]}" "$target"
80 if [ -z "''${dontRemoveDuplicatedDlls-}" ]
83 remove-duplicated-dlls.sh
88 for dllPattern in ${arrayToShell dllFiles} ''${dllFilesArray[@]}
91 for dll in "$target"/$dllPattern
93 [ -f "$dll" ] || continue
94 if pkg-config $(basename -s .dll "$dll")
96 echo "$dll already exported by a buildInputs, not re-exporting"
98 create-pkg-config-for-dll.sh "$out/lib/pkgconfig" "$dll"
104 for exePattern in ${arrayToShell exeFiles} ''${exeFilesArray[@]}
107 for exe in "$target"/$exePattern
109 [ -f "$exe" ] || continue
111 commandName="$(basename -s .exe "$(echo "$exe" | tr "[A-Z]" "[a-z]")")"
114 "$out"/bin/"$commandName" \
115 --add-flags "\"$exe\"" \
124 stdenv.mkDerivation (attrs // (builtins.removeAttrs attrsOrig [ "nativeBuildInputs" ]))