buildDotnetModule: fix structured attributes support

This change refactors internal hooks used by buildDotnetModule to
support derivations with structured attributes. Note that this changes
variable names that the internal hooks expect.

+438 -174
+1 -1
pkgs/applications/misc/ArchiSteamFarm/default.nix
··· 41 doCheck = true; 42 43 preBuild = '' 44 - export projectFile=(ArchiSteamFarm) 45 ''; 46 47 preInstall = ''
··· 41 doCheck = true; 42 43 preBuild = '' 44 + dotnetProjectFiles=(ArchiSteamFarm) 45 ''; 46 47 preInstall = ''
+1 -1
pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix
··· 28 ] ++ (nugetDeps fetchNuGet); 29 }; 30 31 - projectFile = ""; 32 33 useDotnetFromEnv = true; 34
··· 28 ] ++ (nugetDeps fetchNuGet); 29 }; 30 31 + dotnetGlobalTool = true; 32 33 useDotnetFromEnv = true; 34
+24 -12
pkgs/build-support/dotnet/build-dotnet-module/default.nix
··· 69 , disabledTests ? [ ] 70 # The project file to run unit tests against. This is usually referenced in the regular project file, but sometimes it needs to be manually set. 71 # It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this. 72 - , testProjectFile ? "" 73 74 # The type of build to perform. This is passed to `dotnet` with the `--configuration` flag. Possible values are `Release`, `Debug`, etc. 75 , buildType ? "Release" ··· 88 } @ args: 89 90 let 91 platforms = 92 if args ? meta.platforms 93 then lib.intersectLists args.meta.platforms dotnet-sdk.meta.platforms 94 else dotnet-sdk.meta.platforms; 95 96 inherit (callPackage ./hooks { 97 - inherit dotnet-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType; 98 - runtimeId = 99 - if runtimeId != null 100 - then runtimeId 101 - else dotnetCorePackages.systemToDotnetRid stdenvNoCC.targetPlatform.system; 102 }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook; 103 104 localDeps = ··· 143 nugetDepsFile = _nugetDeps.sourceFile; 144 in 145 stdenvNoCC.mkDerivation (args // { 146 nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ 147 dotnetConfigureHook 148 dotnetBuildHook ··· 172 else [ ])); 173 174 makeWrapperArgs = args.makeWrapperArgs or [ ] ++ [ 175 - "--prefix LD_LIBRARY_PATH : ${dotnet-sdk.icu}/lib" 176 ]; 177 178 # Stripping breaks the executable ··· 180 181 # gappsWrapperArgs gets included when wrapping for dotnet, as to avoid double wrapping 182 dontWrapGApps = args.dontWrapGApps or true; 183 - 184 - inherit selfContainedBuild useAppHost useDotnetFromEnv; 185 186 # propagate the runtime sandbox profile since the contents apply to published 187 # executables ··· 267 --no-cache \ 268 --force \ 269 ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \ 270 - ${lib.optionalString (flags != []) (toString flags)} 271 } 272 273 - declare -a projectFiles=( ${toString (lib.toList projectFile)} ) 274 - declare -a testProjectFiles=( ${toString (lib.toList testProjectFile)} ) 275 276 export DOTNET_NOLOGO=1 277 export DOTNET_CLI_TELEMETRY_OPTOUT=1
··· 69 , disabledTests ? [ ] 70 # The project file to run unit tests against. This is usually referenced in the regular project file, but sometimes it needs to be manually set. 71 # It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this. 72 + , testProjectFile ? null 73 74 # The type of build to perform. This is passed to `dotnet` with the `--configuration` flag. Possible values are `Release`, `Debug`, etc. 75 , buildType ? "Release" ··· 88 } @ args: 89 90 let 91 + projectFiles = 92 + lib.optionals (projectFile != null) (lib.toList projectFile); 93 + testProjectFiles = 94 + lib.optionals (testProjectFile != null) (lib.toList testProjectFile); 95 + 96 platforms = 97 if args ? meta.platforms 98 then lib.intersectLists args.meta.platforms dotnet-sdk.meta.platforms 99 else dotnet-sdk.meta.platforms; 100 101 inherit (callPackage ./hooks { 102 + inherit dotnet-sdk dotnet-runtime; 103 }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook; 104 105 localDeps = ··· 144 nugetDepsFile = _nugetDeps.sourceFile; 145 in 146 stdenvNoCC.mkDerivation (args // { 147 + dotnetInstallPath = installPath; 148 + dotnetExecutables = executables; 149 + dotnetBuildType = buildType; 150 + dotnetProjectFiles = projectFiles; 151 + dotnetTestProjectFiles = testProjectFiles; 152 + dotnetDisabledTests = disabledTests; 153 + dotnetRuntimeId = runtimeId; 154 + nugetSource = nuget-source; 155 + dotnetRuntimeDeps = map lib.getLib runtimeDeps; 156 + dotnetSelfContainedBuild = selfContainedBuild; 157 + dotnetUseAppHost = useAppHost; 158 + inherit useDotnetFromEnv; 159 + 160 nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ 161 dotnetConfigureHook 162 dotnetBuildHook ··· 186 else [ ])); 187 188 makeWrapperArgs = args.makeWrapperArgs or [ ] ++ [ 189 + "--prefix" "LD_LIBRARY_PATH" ":" "${dotnet-sdk.icu}/lib" 190 ]; 191 192 # Stripping breaks the executable ··· 194 195 # gappsWrapperArgs gets included when wrapping for dotnet, as to avoid double wrapping 196 dontWrapGApps = args.dontWrapGApps or true; 197 198 # propagate the runtime sandbox profile since the contents apply to published 199 # executables ··· 279 --no-cache \ 280 --force \ 281 ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \ 282 + ${lib.escapeShellArgs flags} 283 } 284 285 + declare -a projectFiles=( ${lib.escapeShellArgs projectFiles} ) 286 + declare -a testProjectFiles=( ${lib.escapeShellArgs testProjectFiles} ) 287 288 export DOTNET_NOLOGO=1 289 export DOTNET_CLI_TELEMETRY_OPTOUT=1
+8 -28
pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix
··· 4 , coreutils 5 , zlib 6 , openssl 7 - , callPackage 8 , makeSetupHook 9 - , makeWrapper 10 , dotnet-sdk 11 - , disabledTests 12 - , nuget-source 13 , dotnet-runtime 14 - , runtimeDeps 15 - , buildType 16 - , runtimeId 17 }: 18 - assert (builtins.isString runtimeId); 19 - 20 let 21 - libraryPath = lib.makeLibraryPath runtimeDeps; 22 in 23 { 24 dotnetConfigureHook = makeSetupHook 25 { 26 name = "dotnet-configure-hook"; 27 substitutions = { 28 - nugetSource = nuget-source; 29 dynamicLinker = "${stdenv.cc}/nix-support/dynamic-linker"; 30 libPath = lib.makeLibraryPath [ 31 stdenv.cc.cc.lib ··· 34 zlib 35 openssl 36 ]; 37 - inherit runtimeId; 38 }; 39 } 40 ./dotnet-configure-hook.sh; ··· 43 { 44 name = "dotnet-build-hook"; 45 substitutions = { 46 - inherit buildType runtimeId; 47 }; 48 } 49 ./dotnet-build-hook.sh; ··· 52 { 53 name = "dotnet-check-hook"; 54 substitutions = { 55 - inherit buildType runtimeId libraryPath; 56 - disabledTests = lib.optionalString (disabledTests != [ ]) 57 - ( 58 - let 59 - escapedNames = lib.lists.map (n: lib.replaceStrings [ "," ] [ "%2C" ] n) disabledTests; 60 - filters = lib.lists.map (n: "FullyQualifiedName!=${n}") escapedNames; 61 - in 62 - "${lib.concatStringsSep "&" filters}" 63 - ); 64 }; 65 } 66 ./dotnet-check-hook.sh; ··· 69 { 70 name = "dotnet-install-hook"; 71 substitutions = { 72 - inherit buildType runtimeId; 73 }; 74 } 75 ./dotnet-install-hook.sh; ··· 79 name = "dotnet-fixup-hook"; 80 substitutions = { 81 dotnetRuntime = dotnet-runtime; 82 - runtimeDeps = libraryPath; 83 - shell = stdenv.shell; 84 - which = "${which}/bin/which"; 85 - dirname = "${coreutils}/bin/dirname"; 86 - realpath = "${coreutils}/bin/realpath"; 87 }; 88 } 89 ./dotnet-fixup-hook.sh;
··· 4 , coreutils 5 , zlib 6 , openssl 7 , makeSetupHook 8 + , dotnetCorePackages 9 + # Passed from ../default.nix 10 , dotnet-sdk 11 , dotnet-runtime 12 }: 13 let 14 + runtimeId = dotnetCorePackages.systemToDotnetRid stdenv.hostPlatform.system; 15 in 16 { 17 dotnetConfigureHook = makeSetupHook 18 { 19 name = "dotnet-configure-hook"; 20 substitutions = { 21 + runtimeId = lib.escapeShellArg runtimeId; 22 dynamicLinker = "${stdenv.cc}/nix-support/dynamic-linker"; 23 libPath = lib.makeLibraryPath [ 24 stdenv.cc.cc.lib ··· 27 zlib 28 openssl 29 ]; 30 }; 31 } 32 ./dotnet-configure-hook.sh; ··· 35 { 36 name = "dotnet-build-hook"; 37 substitutions = { 38 + runtimeId = lib.escapeShellArg runtimeId; 39 }; 40 } 41 ./dotnet-build-hook.sh; ··· 44 { 45 name = "dotnet-check-hook"; 46 substitutions = { 47 + runtimeId = lib.escapeShellArg runtimeId; 48 }; 49 } 50 ./dotnet-check-hook.sh; ··· 53 { 54 name = "dotnet-install-hook"; 55 substitutions = { 56 + runtimeId = lib.escapeShellArg runtimeId; 57 }; 58 } 59 ./dotnet-install-hook.sh; ··· 63 name = "dotnet-fixup-hook"; 64 substitutions = { 65 dotnetRuntime = dotnet-runtime; 66 + wrapperPath = lib.makeBinPath [ which coreutils ]; 67 }; 68 } 69 ./dotnet-fixup-hook.sh;
+46 -30
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
··· 1 - # inherit arguments from derivation 2 - dotnetBuildFlags=( ${dotnetBuildFlags[@]-} ) 3 - 4 dotnetBuildHook() { 5 echo "Executing dotnetBuildHook" 6 7 runHook preBuild 8 9 - if [ "${enableParallelBuilding-}" ]; then 10 local -r maxCpuFlag="$NIX_BUILD_CORES" 11 local -r parallelBuildFlag="true" 12 else ··· 14 local -r parallelBuildFlag="false" 15 fi 16 17 - if [ "${selfContainedBuild-}" ]; then 18 - dotnetBuildFlags+=("-p:SelfContained=true") 19 else 20 - dotnetBuildFlags+=("-p:SelfContained=false") 21 fi 22 23 - if [ "${useAppHost-}" ]; then 24 - dotnetBuildFlags+=("-p:UseAppHost=true") 25 fi 26 27 - local versionFlags=() 28 - if [ "${version-}" ]; then 29 - versionFlags+=("-p:InformationalVersion=${version-}") 30 fi 31 32 - if [ "${versionForDotnet-}" ]; then 33 - versionFlags+=("-p:Version=${versionForDotnet-}") 34 fi 35 36 dotnetBuild() { 37 - local -r project="${1-}" 38 39 - runtimeIdFlags=() 40 - if [[ "$project" == *.csproj ]] || [ "${selfContainedBuild-}" ]; then 41 - runtimeIdFlags+=("--runtime @runtimeId@") 42 fi 43 44 - dotnet build ${project-} \ 45 - -maxcpucount:$maxCpuFlag \ 46 - -p:BuildInParallel=$parallelBuildFlag \ 47 -p:ContinuousIntegrationBuild=true \ 48 -p:Deterministic=true \ 49 - --configuration "@buildType@" \ 50 --no-restore \ 51 - ${versionFlags[@]} \ 52 - ${runtimeIdFlags[@]} \ 53 - ${dotnetBuildFlags[@]} \ 54 - ${dotnetFlags[@]} 55 } 56 57 - (( "${#projectFile[@]}" == 0 )) && dotnetBuild 58 59 - for project in ${projectFile[@]} ${testProjectFile[@]-}; do 60 - dotnetBuild "$project" 61 done 62 63 runHook postBuild ··· 65 echo "Finished dotnetBuildHook" 66 } 67 68 - if [[ -z "${dontDotnetBuild-}" && -z "${buildPhase-}" ]]; then 69 buildPhase=dotnetBuildHook 70 fi
··· 1 dotnetBuildHook() { 2 echo "Executing dotnetBuildHook" 3 4 runHook preBuild 5 6 + local -r hostRuntimeId=@runtimeId@ 7 + local -r dotnetBuildType="${dotnetBuildType-Release}" 8 + local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}" 9 + 10 + if [[ -n $__structuredAttrs ]]; then 11 + local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" ) 12 + local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" ) 13 + local dotnetFlagsArray=( "${dotnetFlags[@]}" ) 14 + local dotnetBuildFlagsArray=( "${dotnetBuildFlags[@]}" ) 15 + else 16 + local dotnetProjectFilesArray=($dotnetProjectFiles) 17 + local dotnetTestProjectFilesArray=($dotnetTestProjectFiles) 18 + local dotnetFlagsArray=($dotnetFlags) 19 + local dotnetBuildFlagsArray=($dotnetBuildFlags) 20 + fi 21 + 22 + if [[ -n "${enableParallelBuilding-}" ]]; then 23 local -r maxCpuFlag="$NIX_BUILD_CORES" 24 local -r parallelBuildFlag="true" 25 else ··· 27 local -r parallelBuildFlag="false" 28 fi 29 30 + if [[ -n ${dotnetSelfContainedBuild-} ]]; then 31 + dotnetBuildFlagsArray+=("-p:SelfContained=true") 32 else 33 + dotnetBuildFlagsArray+=("-p:SelfContained=false") 34 fi 35 36 + if [[ -n ${dotnetUseAppHost-} ]]; then 37 + dotnetBuildFlagsArray+=("-p:UseAppHost=true") 38 fi 39 40 + local versionFlagsArray=() 41 + if [[ -n ${version-} ]]; then 42 + versionFlagsArray+=("-p:InformationalVersion=$version") 43 fi 44 45 + if [[ -n ${versionForDotnet-} ]]; then 46 + versionFlagsArray+=("-p:Version=$versionForDotnet") 47 fi 48 49 dotnetBuild() { 50 + local -r projectFile="${1-}" 51 52 + local runtimeIdFlagsArray=() 53 + if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then 54 + runtimeIdFlagsArray+=("--runtime" "$dotnetRuntimeId") 55 fi 56 57 + dotnet build ${1+"$projectFile"} \ 58 + -maxcpucount:"$maxCpuFlag" \ 59 + -p:BuildInParallel="$parallelBuildFlag" \ 60 -p:ContinuousIntegrationBuild=true \ 61 -p:Deterministic=true \ 62 + --configuration "$dotnetBuildType" \ 63 --no-restore \ 64 + "${versionFlagsArray[@]}" \ 65 + "${runtimeIdFlagsArray[@]}" \ 66 + "${dotnetBuildFlagsArray[@]}" \ 67 + "${dotnetFlagsArray[@]}" 68 } 69 70 + if (( ${#dotnetProjectFilesArray[@]} == 0 )); then 71 + dotnetBuild 72 + fi 73 74 + local projectFile 75 + for projectFile in "${dotnetProjectFilesArray[@]}" "${dotnetTestProjectFilesArray[@]}"; do 76 + dotnetBuild "$projectFile" 77 done 78 79 runHook postBuild ··· 81 echo "Finished dotnetBuildHook" 82 } 83 84 + if [[ -z ${dontDotnetBuild-} && -z ${buildPhase-} ]]; then 85 buildPhase=dotnetBuildHook 86 fi
+44 -18
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
··· 1 - # inherit arguments from derivation 2 - dotnetTestFlags=( ${dotnetTestFlags[@]-} ) 3 - 4 dotnetCheckHook() { 5 echo "Executing dotnetCheckHook" 6 7 runHook preCheck 8 9 - if [ "${disabledTests-}" ]; then 10 - local -r disabledTestsFlag="--filter @disabledTests@" 11 fi 12 13 - if [ "${enableParallelBuilding-}" ]; then 14 local -r maxCpuFlag="$NIX_BUILD_CORES" 15 else 16 local -r maxCpuFlag="1" 17 fi 18 19 - for project in ${testProjectFile[@]-${projectFile[@]}}; do 20 - runtimeIdFlags=() 21 - if [[ "$project" == *.csproj ]]; then 22 - runtimeIdFlags=("--runtime @runtimeId@") 23 fi 24 25 - LD_LIBRARY_PATH="@libraryPath@" \ 26 - dotnet test "$project" \ 27 - -maxcpucount:$maxCpuFlag \ 28 -p:ContinuousIntegrationBuild=true \ 29 -p:Deterministic=true \ 30 - --configuration "@buildType@" \ 31 --no-build \ 32 --logger "console;verbosity=normal" \ 33 - ${disabledTestsFlag-} \ 34 - ${runtimeIdFlags[@]} \ 35 - "${dotnetTestFlags[@]}" \ 36 - "${dotnetFlags[@]}" 37 done 38 39 runHook postCheck
··· 1 dotnetCheckHook() { 2 echo "Executing dotnetCheckHook" 3 4 runHook preCheck 5 6 + local -r hostRuntimeId=@runtimeId@ 7 + local -r dotnetBuildType="${dotnetBuildType-Release}" 8 + local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}" 9 + 10 + if [[ -n $__structuredAttrs ]]; then 11 + local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" ) 12 + local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" ) 13 + local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" ) 14 + local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" ) 15 + local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" ) 16 + else 17 + local dotnetProjectFilesArray=($dotnetProjectFiles) 18 + local dotnetTestProjectFilesArray=($dotnetTestProjectFiles) 19 + local dotnetTestFlagsArray=($dotnetTestFlags) 20 + local dotnetDisabledTestsArray=($dotnetDisabledTests) 21 + local dotnetRuntimeDepsArray=($dotnetRuntimeDeps) 22 + fi 23 + 24 + if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then 25 + local disabledTestsFilters=("${dotnetDisabledTestsArray[@]/#/FullyQualifiedName!=}") 26 + local OLDIFS="$IFS" IFS='&' 27 + dotnetTestFlagsArray+=("--filter:${disabledTestsFilters[*]//,/%2C}") 28 + IFS="$OLDIFS" 29 fi 30 31 + local libraryPath="${LD_LIBRARY_PATH-}" 32 + if (( ${#dotnetRuntimeDepsArray[@]} > 0 )); then 33 + local libraryPathArray=("${dotnetRuntimeDepsArray[@]/%//lib}") 34 + local OLDIFS="$IFS" IFS=':' 35 + libraryPath="${libraryPathArray[*]}${libraryPath:+':'}$libraryPath" 36 + IFS="$OLDIFS" 37 + fi 38 + 39 + if [[ -n ${enableParallelBuilding-} ]]; then 40 local -r maxCpuFlag="$NIX_BUILD_CORES" 41 else 42 local -r maxCpuFlag="1" 43 fi 44 45 + local projectFile 46 + for projectFile in "${dotnetTestProjectFilesArray[@]-${dotnetProjectFilesArray[@]}}"; do 47 + local runtimeIdFlagsArray=() 48 + if [[ $projectFile == *.csproj ]]; then 49 + runtimeIdFlagsArray=("--runtime" "$dotnetRuntimeId") 50 fi 51 52 + LD_LIBRARY_PATH=$libraryPath \ 53 + dotnet test "$projectFile" \ 54 + -maxcpucount:"$maxCpuFlag" \ 55 -p:ContinuousIntegrationBuild=true \ 56 -p:Deterministic=true \ 57 + --configuration "$dotnetBuildType" \ 58 --no-build \ 59 --logger "console;verbosity=normal" \ 60 + "${runtimeIdFlagsArray[@]}" \ 61 + "${dotnetTestFlagsArray[@]}" \ 62 + "${dotnetFlagsArray[@]}" 63 done 64 65 runHook postCheck
+67 -27
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh
··· 1 - declare -a projectFile testProjectFile 2 - 3 - # Inherit arguments from derivation 4 - dotnetFlags=( ${dotnetFlags[@]-} ) 5 - dotnetRestoreFlags=( ${dotnetRestoreFlags[@]-} ) 6 - 7 dotnetConfigureHook() { 8 echo "Executing dotnetConfigureHook" 9 10 runHook preConfigure 11 12 - if [ -z "${enableParallelBuilding-}" ]; then 13 local -r parallelFlag="--disable-parallel" 14 fi 15 16 dotnetRestore() { 17 - local -r project="${1-}" 18 - dotnet restore ${project-} \ 19 -p:ContinuousIntegrationBuild=true \ 20 -p:Deterministic=true \ 21 - --runtime "@runtimeId@" \ 22 - --source "@nugetSource@/lib" \ 23 ${parallelFlag-} \ 24 - ${dotnetRestoreFlags[@]} \ 25 - ${dotnetFlags[@]} 26 } 27 28 # Generate a NuGet.config file to make sure everything, 29 # including things like <Sdk /> dependencies, is restored from the proper source 30 - cat <<EOF > "./NuGet.config" 31 <?xml version="1.0" encoding="utf-8"?> 32 <configuration> 33 <packageSources> 34 <clear /> 35 - <add key="nugetSource" value="@nugetSource@/lib" /> 36 </packageSources> 37 </configuration> 38 EOF 39 40 - # Patch paket.dependencies and paket.lock (if found) to use the proper source. This ensures 41 - # paket restore works correctly 42 - # We use + instead of / in sed to avoid problems with slashes 43 - find -name paket.dependencies -exec sed -i 's+source .*+source @nugetSource@/lib+g' {} \; 44 - find -name paket.lock -exec sed -i 's+remote:.*+remote: @nugetSource@/lib+g' {} \; 45 46 - dotnet tool restore --add-source "@nugetSource@/lib" 47 48 - (( "${#projectFile[@]}" == 0 )) && dotnetRestore 49 50 - for project in ${projectFile[@]} ${testProjectFile[@]-}; do 51 - dotnetRestore "$project" 52 - done 53 54 echo "Fixing up native binaries..." 55 # Find all native binaries and nuget libraries, and fix them up, 56 # by setting the proper interpreter and rpath to some commonly used libraries 57 for binary in $(find "$HOME/.nuget/packages/" -type f -executable); do 58 if patchelf --print-interpreter "$binary" >/dev/null 2>/dev/null; then 59 echo "Found binary: $binary, fixing it up..." 60 - patchelf --set-interpreter "$(cat "@dynamicLinker@")" "$binary" 61 62 # This makes sure that if the binary requires some specific runtime dependencies, it can find it. 63 # This fixes dotnet-built binaries like crossgen2 ··· 68 --add-needed libssl.so \ 69 "$binary" 70 71 - patchelf --set-rpath "@libPath@" "$binary" 72 fi 73 done 74
··· 1 dotnetConfigureHook() { 2 echo "Executing dotnetConfigureHook" 3 4 runHook preConfigure 5 6 + if [[ -z ${nugetSource-} ]]; then 7 + echo 8 + echo "ERROR: no dependencies were specified" 9 + echo 'Hint: set `nugetSource` if using these hooks individually. If this is happening with `buildDotnetModule`, please open an issue.' 10 + echo 11 + 12 + exit 1 13 + fi 14 + 15 + local nugetSourceSedQuoted="${nugetSource//[\/\\&$'\n']/\\&}" 16 + local nugetSourceXMLQuoted="$nugetSource" 17 + nugetSourceXMLQuoted="${nugetSource//&/\&amp;}" 18 + nugetSourceXMLQuoted="${nugetSourceXMLQuoted//\"/\&quot;}" 19 + 20 + local -r hostRuntimeId=@runtimeId@ 21 + local -r dynamicLinker=@dynamicLinker@ 22 + local -r libPath=@libPath@ 23 + local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}" 24 + 25 + if [[ -n $__structuredAttrs ]]; then 26 + local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" ) 27 + local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" ) 28 + local dotnetFlagsArray=( "${dotnetFlags[@]}" ) 29 + local dotnetRestoreFlagsArray=( "${dotnetRestoreFlags[@]}" ) 30 + else 31 + local dotnetProjectFilesArray=($dotnetProjectFiles) 32 + local dotnetTestProjectFilesArray=($dotnetTestProjectFiles) 33 + local dotnetFlagsArray=($dotnetFlags) 34 + local dotnetRestoreFlagsArray=($dotnetRestoreFlags) 35 + fi 36 + 37 + if [[ -z ${enableParallelBuilding-} ]]; then 38 local -r parallelFlag="--disable-parallel" 39 fi 40 41 dotnetRestore() { 42 + local -r projectFile="${1-}" 43 + dotnet restore ${1+"$projectFile"} \ 44 -p:ContinuousIntegrationBuild=true \ 45 -p:Deterministic=true \ 46 + --runtime "$dotnetRuntimeId" \ 47 + --source "$nugetSource/lib" \ 48 ${parallelFlag-} \ 49 + "${dotnetRestoreFlagsArray[@]}" \ 50 + "${dotnetFlagsArray[@]}" 51 } 52 53 # Generate a NuGet.config file to make sure everything, 54 # including things like <Sdk /> dependencies, is restored from the proper source 55 + cat >NuGet.config <<EOF 56 <?xml version="1.0" encoding="utf-8"?> 57 <configuration> 58 <packageSources> 59 <clear /> 60 + <add key="nugetSource" value="$nugetSourceXMLQuoted/lib" /> 61 </packageSources> 62 </configuration> 63 EOF 64 65 + # Patch paket.dependencies and paket.lock (if found) to use the proper 66 + # source. This ensures paket restore works correctly. Note that the 67 + # nugetSourceSedQuoted abomination below safely escapes nugetSource string 68 + # for use as a sed replacement string to avoid issues with slashes and other 69 + # special characters ('&', '\\' and '\n'). 70 + find -name paket.dependencies -exec sed -i "s/source .*/source $nugetSourceSedQuoted\/lib/g" {} \; 71 + find -name paket.lock -exec sed -i "s/remote:.*/remote: $nugetSourceSedQuoted\/lib/g" {} \; 72 73 + dotnet tool restore --add-source "$nugetSource/lib" 74 75 + # dotnetGlobalTool is set in buildDotnetGlobalTool to patch dependencies but 76 + # avoid other project-specific logic. This is a hack, but the old behavior 77 + # is worse as it relied on a bug: setting projectFile to an empty string 78 + # made the hooks actually skip all project-specific logic. It’s hard to keep 79 + # backwards compatibility with this odd behavior now since we are using 80 + # arrays, so instead we just pass a variable to indicate that we don’t have 81 + # projects. 82 + if [[ -z ${dotnetGlobalTool-} ]]; then 83 + if (( ${#dotnetProjectFilesArray[@]} == 0 )); then 84 + dotnetRestore 85 + fi 86 87 + local projectFile 88 + for projectFile in "${dotnetProjectFilesArray[@]}" "${dotnetTestProjectFilesArray[@]}"; do 89 + dotnetRestore "$projectFile" 90 + done 91 + fi 92 93 echo "Fixing up native binaries..." 94 # Find all native binaries and nuget libraries, and fix them up, 95 # by setting the proper interpreter and rpath to some commonly used libraries 96 + local binary 97 for binary in $(find "$HOME/.nuget/packages/" -type f -executable); do 98 if patchelf --print-interpreter "$binary" >/dev/null 2>/dev/null; then 99 echo "Found binary: $binary, fixing it up..." 100 + patchelf --set-interpreter "$(cat "$dynamicLinker")" "$binary" 101 102 # This makes sure that if the binary requires some specific runtime dependencies, it can find it. 103 # This fixes dotnet-built binaries like crossgen2 ··· 108 --add-needed libssl.so \ 109 "$binary" 110 111 + patchelf --set-rpath "$libPath" "$binary" 112 fi 113 done 114
+60 -21
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
··· 1 - # Inherit arguments from the derivation 2 - declare -a derivationMakeWrapperArgs="( ${makeWrapperArgs-} )" 3 - makeWrapperArgs=( "${derivationMakeWrapperArgs[@]}" ) 4 - 5 # First argument is the executable you want to wrap, 6 # the second is the destination for the wrapper. 7 wrapDotnetProgram() { 8 - local dotnetRootFlags=() 9 10 - if [ ! "${selfContainedBuild-}" ]; then 11 - if [ "${useDotnetFromEnv-}" ]; then 12 # if dotnet CLI is available, set DOTNET_ROOT based on it. Otherwise set to default .NET runtime 13 - dotnetRootFlags+=("--run" 'command -v dotnet &>/dev/null && export DOTNET_ROOT="$(@dirname@ "$(@realpath@ "$(@which@ dotnet)")")" || export DOTNET_ROOT="@dotnetRuntime@"') 14 - dotnetRootFlags+=("--suffix" "PATH" ":" "@dotnetRuntime@/bin") 15 else 16 - dotnetRootFlags+=("--set" "DOTNET_ROOT" "@dotnetRuntime@") 17 - dotnetRootFlags+=("--prefix" "PATH" ":" "@dotnetRuntime@/bin") 18 fi 19 fi 20 21 makeWrapper "$1" "$2" \ 22 - --suffix "LD_LIBRARY_PATH" : "@runtimeDeps@" \ 23 - "${dotnetRootFlags[@]}" \ 24 "${gappsWrapperArgs[@]}" \ 25 - "${makeWrapperArgs[@]}" 26 27 echo "installed wrapper to "$2"" 28 } ··· 30 dotnetFixupHook() { 31 echo "Executing dotnetFixupPhase" 32 33 - # check if executables is declared (including empty values, in which case we generate no executables) 34 - if declare -p executables &>/dev/null; then 35 - for executable in ${executables[@]}; do 36 - path="${installPath-$out/lib/$pname}/$executable" 37 38 if test -x "$path"; then 39 - wrapDotnetProgram "$path" "$out/bin/$(basename "$executable")" 40 else 41 echo "Specified binary \"$executable\" is either not an executable or does not exist!" 42 echo "Looked in $path" ··· 45 done 46 else 47 while IFS= read -d '' executable; do 48 - wrapDotnetProgram "$executable" "$out/bin/$(basename "$executable")" \; 49 - done < <(find "${installPath-$out/lib/$pname}" ! -name "*.dll" -executable -type f -print0) 50 fi 51 52 echo "Finished dotnetFixupPhase"
··· 1 # First argument is the executable you want to wrap, 2 # the second is the destination for the wrapper. 3 wrapDotnetProgram() { 4 + local -r dotnetRuntime=@dotnetRuntime@ 5 + local -r wrapperPath=@wrapperPath@ 6 + 7 + local -r dotnetFromEnvScript='dotnetFromEnv() { 8 + local dotnetPath 9 + if command -v dotnet 2>&1 >/dev/null; then 10 + dotnetPath=$(which dotnet) && \ 11 + dotnetPath=$(realpath "$dotnetPath") && \ 12 + dotnetPath=$(dirname "$dotnetPath") && \ 13 + export DOTNET_ROOT="$dotnetPath" 14 + fi 15 + } 16 + dotnetFromEnv' 17 + 18 + if [[ -n $__structuredAttrs ]]; then 19 + local -r dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" ) 20 + local -r makeWrapperArgsArray=( "${makeWrapperArgs[@]}" ) 21 + else 22 + local -r dotnetRuntimeDepsArray=($dotnetRuntimeDeps) 23 + local -r makeWrapperArgsArray=($makeWrapperArgs) 24 + fi 25 26 + local dotnetRuntimeDepsFlags=() 27 + if (( ${#dotnetRuntimeDepsArray[@]} > 0 )); then 28 + local libraryPathArray=("${dotnetRuntimeDepsArray[@]/%//lib}") 29 + local OLDIFS="$IFS" IFS=':' 30 + dotnetRuntimeDepsFlags+=("--suffix" "LD_LIBRARY_PATH" ":" "${libraryPathArray[*]}") 31 + IFS="$OLDIFS" 32 + fi 33 + 34 + local dotnetRootFlagsArray=() 35 + if [[ -z ${dotnetSelfContainedBuild-} ]]; then 36 + if [[ -n ${useDotnetFromEnv-} ]]; then 37 # if dotnet CLI is available, set DOTNET_ROOT based on it. Otherwise set to default .NET runtime 38 + dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$wrapperPath") 39 + dotnetRootFlagsArray+=("--run" "$dotnetFromEnvScript") 40 + dotnetRootFlagsArray+=("--set-default" "DOTNET_ROOT" "$dotnetRuntime") 41 + dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$dotnetRuntime/bin") 42 else 43 + dotnetRootFlagsArray+=("--set" "DOTNET_ROOT" "$dotnetRuntime") 44 + dotnetRootFlagsArray+=("--prefix" "PATH" ":" "$dotnetRuntime/bin") 45 fi 46 fi 47 48 makeWrapper "$1" "$2" \ 49 + "${dotnetRuntimeDepsFlags[@]}" \ 50 + "${dotnetRootFlagsArray[@]}" \ 51 "${gappsWrapperArgs[@]}" \ 52 + "${makeWrapperArgsArray[@]}" 53 54 echo "installed wrapper to "$2"" 55 } ··· 57 dotnetFixupHook() { 58 echo "Executing dotnetFixupPhase" 59 60 + local -r dotnetInstallPath="${dotnetInstallPath-$out/lib/$pname}" 61 + 62 + local executable executableBasename 63 + 64 + # check if dotnetExecutables is declared (including empty values, in which case we generate no executables) 65 + if declare -p dotnetExecutables &>/dev/null; then 66 + if [[ -n $__structuredAttrs ]]; then 67 + local dotnetExecutablesArray=( "${dotnetExecutables[@]}" ) 68 + else 69 + local dotnetExecutablesArray=($dotnetExecutables) 70 + fi 71 + for executable in "${dotnetExecutablesArray[@]}"; do 72 + executableBasename=$(basename "$executable") 73 + 74 + local path="$dotnetInstallPath/$executable" 75 76 if test -x "$path"; then 77 + wrapDotnetProgram "$path" "$out/bin/$executableBasename" 78 else 79 echo "Specified binary \"$executable\" is either not an executable or does not exist!" 80 echo "Looked in $path" ··· 83 done 84 else 85 while IFS= read -d '' executable; do 86 + executableBasename=$(basename "$executable") 87 + wrapDotnetProgram "$executable" "$out/bin/$executableBasename" \; 88 + done < <(find "$dotnetInstallPath" ! -name "*.dll" -executable -type f -print0) 89 fi 90 91 echo "Finished dotnetFixupPhase"
+48 -32
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh
··· 1 - # inherit arguments from derivation 2 - dotnetInstallFlags=( ${dotnetInstallFlags[@]-} ) 3 - 4 dotnetInstallHook() { 5 echo "Executing dotnetInstallHook" 6 7 runHook preInstall 8 9 - if [ "${selfContainedBuild-}" ]; then 10 - dotnetInstallFlags+=("--self-contained") 11 else 12 - dotnetInstallFlags+=("--no-self-contained") 13 # https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained 14 # Trimming is only available for self-contained build, so force disable it here 15 - dotnetInstallFlags+=("-p:PublishTrimmed=false") 16 fi 17 18 - if [ "${useAppHost-}" ]; then 19 - dotnetInstallFlags+=("-p:UseAppHost=true") 20 fi 21 22 dotnetPublish() { 23 - local -r project="${1-}" 24 25 - runtimeIdFlags=() 26 - if [[ "$project" == *.csproj ]] || [ "${selfContainedBuild-}" ]; then 27 - runtimeIdFlags+=("--runtime @runtimeId@") 28 fi 29 30 - dotnet publish ${project-} \ 31 -p:ContinuousIntegrationBuild=true \ 32 -p:Deterministic=true \ 33 - --output "${installPath-$out/lib/$pname}" \ 34 - --configuration "@buildType@" \ 35 --no-build \ 36 - ${runtimeIdFlags[@]} \ 37 - ${dotnetInstallFlags[@]} \ 38 - ${dotnetFlags[@]} 39 } 40 41 dotnetPack() { 42 - local -r project="${1-}" 43 - dotnet pack ${project-} \ 44 -p:ContinuousIntegrationBuild=true \ 45 -p:Deterministic=true \ 46 --output "$out/share" \ 47 - --configuration "@buildType@" \ 48 --no-build \ 49 - --runtime "@runtimeId@" \ 50 - ${dotnetPackFlags[@]} \ 51 - ${dotnetFlags[@]} 52 } 53 54 - if (( "${#projectFile[@]}" == 0 )); then 55 dotnetPublish 56 else 57 - for project in ${projectFile[@]}; do 58 - dotnetPublish "$project" 59 done 60 fi 61 62 - if [[ "${packNupkg-}" ]]; then 63 - if (( "${#projectFile[@]}" == 0 )); then 64 dotnetPack 65 else 66 - for project in ${projectFile[@]}; do 67 - dotnetPack "$project" 68 done 69 fi 70 fi
··· 1 dotnetInstallHook() { 2 echo "Executing dotnetInstallHook" 3 4 runHook preInstall 5 6 + local -r hostRuntimeId=@runtimeId@ 7 + local -r dotnetInstallPath="${dotnetInstallPath-$out/lib/$pname}" 8 + local -r dotnetBuildType="${dotnetBuildType-Release}" 9 + local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}" 10 + 11 + if [[ -n $__structuredAttrs ]]; then 12 + local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" ) 13 + local dotnetFlagsArray=( "${dotnetFlags[@]}" ) 14 + local dotnetInstallFlagsArray=( "${dotnetInstallFlags[@]}" ) 15 + local dotnetPackFlagsArray=( "${dotnetPackFlags[@]}" ) 16 else 17 + local dotnetProjectFilesArray=($dotnetProjectFiles) 18 + local dotnetFlagsArray=($dotnetFlags) 19 + local dotnetInstallFlagsArray=($dotnetInstallFlags) 20 + local dotnetPackFlagsArray=($dotnetPackFlags) 21 + fi 22 + 23 + if [[ -n ${dotnetSelfContainedBuild-} ]]; then 24 + dotnetInstallFlagsArray+=("--self-contained") 25 + else 26 + dotnetInstallFlagsArray+=("--no-self-contained") 27 # https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained 28 # Trimming is only available for self-contained build, so force disable it here 29 + dotnetInstallFlagsArray+=("-p:PublishTrimmed=false") 30 fi 31 32 + if [[ -n ${dotnetUseAppHost-} ]]; then 33 + dotnetInstallFlagsArray+=("-p:UseAppHost=true") 34 fi 35 36 dotnetPublish() { 37 + local -r projectFile="${1-}" 38 39 + runtimeIdFlagsArray=() 40 + if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then 41 + runtimeIdFlagsArray+=("--runtime" "$dotnetRuntimeId") 42 fi 43 44 + dotnet publish ${1+"$projectFile"} \ 45 -p:ContinuousIntegrationBuild=true \ 46 -p:Deterministic=true \ 47 + --output "$dotnetInstallPath" \ 48 + --configuration "$dotnetBuildType" \ 49 --no-build \ 50 + "${runtimeIdFlagsArray[@]}" \ 51 + "${dotnetInstallFlagsArray[@]}" \ 52 + "${dotnetFlagsArray[@]}" 53 } 54 55 dotnetPack() { 56 + local -r projectFile="${1-}" 57 + dotnet pack ${1+"$projectFile"} \ 58 -p:ContinuousIntegrationBuild=true \ 59 -p:Deterministic=true \ 60 --output "$out/share" \ 61 + --configuration "$dotnetBuildType" \ 62 --no-build \ 63 + --runtime "$dotnetRuntimeId" \ 64 + "${dotnetPackFlagsArray[@]}" \ 65 + "${dotnetFlagsArray[@]}" 66 } 67 68 + if (( ${#dotnetProjectFilesArray[@]} == 0 )); then 69 dotnetPublish 70 else 71 + local projectFile 72 + for projectFile in "${dotnetProjectFilesArray[@]}"; do 73 + dotnetPublish "$projectFile" 74 done 75 fi 76 77 + if [[ -n ${packNupkg-} ]]; then 78 + if (( ${#dotnetProjectFilesArray[@]} == 0 )); then 79 dotnetPack 80 else 81 + local projectFile 82 + for projectFile in "${dotnetProjectFilesArray[@]}"; do 83 + dotnetPack "$projectFile" 84 done 85 fi 86 fi
+3 -1
pkgs/test/dotnet/default.nix
··· 1 - { callPackage }: 2 3 { 4 project-references = callPackage ./project-references { }; 5 }
··· 1 + { lib, callPackage }: 2 3 { 4 project-references = callPackage ./project-references { }; 5 + use-dotnet-from-env = lib.recurseIntoAttrs (callPackage ./use-dotnet-from-env { }); 6 + structured-attrs = lib.recurseIntoAttrs (callPackage ./structured-attrs { }); 7 }
+7 -3
pkgs/test/dotnet/project-references/default.nix
··· 4 5 { lib 6 , dotnet-sdk 7 - , buildDotnetModule 8 , runCommand 9 }: 10 11 let 12 nugetDeps = ./nuget-deps.nix; 13 14 # Specify the TargetFramework via an environment variable so that we don't ··· 18 library = buildDotnetModule { 19 name = "project-references-test-library"; 20 src = ./library; 21 - inherit nugetDeps TargetFramework; 22 23 packNupkg = true; 24 }; ··· 26 application = buildDotnetModule { 27 name = "project-references-test-application"; 28 src = ./application; 29 - inherit nugetDeps TargetFramework; 30 31 projectReferences = [ library ]; 32 };
··· 4 5 { lib 6 , dotnet-sdk 7 + , buildPackages # buildDotnetModule 8 , runCommand 9 }: 10 11 let 12 + inherit (buildPackages) buildDotnetModule; 13 + 14 nugetDeps = ./nuget-deps.nix; 15 16 # Specify the TargetFramework via an environment variable so that we don't ··· 20 library = buildDotnetModule { 21 name = "project-references-test-library"; 22 src = ./library; 23 + inherit nugetDeps; 24 + env.TargetFramework = TargetFramework; 25 26 packNupkg = true; 27 }; ··· 29 application = buildDotnetModule { 30 name = "project-references-test-application"; 31 src = ./application; 32 + inherit nugetDeps; 33 + env.TargetFramework = TargetFramework; 34 35 projectReferences = [ library ]; 36 };
+36
pkgs/test/dotnet/structured-attrs/default.nix
···
··· 1 + { lib 2 + , dotnet-sdk 3 + , buildPackages # buildDotnetModule 4 + , testers 5 + , runCommand 6 + }: 7 + let 8 + # Note: without structured attributes, we can’t use derivation arguments that 9 + # contain spaces unambiguously because arguments are passed as space-separated 10 + # environment variables. 11 + copyrightString = "Public domain 🅮"; 12 + 13 + inherit (buildPackages) buildDotnetModule; 14 + 15 + app = buildDotnetModule { 16 + name = "structured-attrs-test-application"; 17 + src = ./src; 18 + nugetDeps = ./nuget-deps.nix; 19 + dotnetFlags = [ "--property:Copyright=${copyrightString}" ]; 20 + env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}"; 21 + __structuredAttrs = true; 22 + }; 23 + in 24 + { 25 + no-structured-attrs = testers.testBuildFailure (app.overrideAttrs { 26 + __structuredAttrs = false; 27 + }); 28 + 29 + check-output = testers.testEqualContents { 30 + assertion = "buildDotnetModule sets AssemblyCopyrightAttribute with structured attributes"; 31 + expected = builtins.toFile "expected-copyright.txt" copyrightString; 32 + actual = runCommand "dotnet-structured-attrs-test" { } '' 33 + ${app}/bin/Application >"$out" 34 + ''; 35 + }; 36 + }
+5
pkgs/test/dotnet/structured-attrs/nuget-deps.nix
···
··· 1 + # This file was automatically generated by passthru.fetch-deps. 2 + # Please dont edit it manually, your changes might get overwritten! 3 + 4 + { fetchNuGet }: [ 5 + ]
+10
pkgs/test/dotnet/structured-attrs/src/Application.cs
···
··· 1 + using System; 2 + using System.Reflection; 3 + 4 + Console.Write( 5 + ( 6 + (AssemblyCopyrightAttribute)Assembly 7 + .GetExecutingAssembly() 8 + .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true)[0] 9 + ).Copyright 10 + );
+5
pkgs/test/dotnet/structured-attrs/src/Application.csproj
···
··· 1 + <Project Sdk="Microsoft.NET.Sdk"> 2 + <PropertyGroup> 3 + <OutputType>exe</OutputType> 4 + </PropertyGroup> 5 + </Project>
+60
pkgs/test/dotnet/use-dotnet-from-env/default.nix
···
··· 1 + { lib 2 + , dotnet-sdk 3 + , buildPackages # buildDotnetModule, dotnet-runtime 4 + , testers 5 + , runCommand 6 + , removeReferencesTo 7 + }: 8 + let 9 + inherit (buildPackages) buildDotnetModule dotnet-runtime; 10 + 11 + app = buildDotnetModule { 12 + name = "use-dotnet-from-env-test-application"; 13 + src = ./src; 14 + nugetDeps = ./nuget-deps.nix; 15 + useDotnetFromEnv = true; 16 + env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}"; 17 + }; 18 + 19 + appWithoutFallback = app.overrideAttrs (oldAttrs: { 20 + nativeBuildInputs = (oldAttrs.nativeBuildInputs or [ ]) ++ [ 21 + removeReferencesTo 22 + ]; 23 + postFixup = (oldAttrs.postFixup or "") + '' 24 + remove-references-to -t ${dotnet-runtime} "$out/bin/Application" 25 + ''; 26 + }); 27 + 28 + runtimeVersion = lib.getVersion dotnet-runtime; 29 + runtimeVersionFile = builtins.toFile "dotnet-version.txt" runtimeVersion; 30 + in 31 + { 32 + fallback = testers.testEqualContents { 33 + assertion = "buildDotnetModule sets fallback DOTNET_ROOT in wrapper"; 34 + expected = runtimeVersionFile; 35 + actual = runCommand "use-dotnet-from-env-fallback-test" { } '' 36 + ${app}/bin/Application >"$out" 37 + ''; 38 + }; 39 + 40 + # Check that appWithoutFallback does not use fallback .NET runtime. 41 + without-fallback = testers.testBuildFailure (runCommand "use-dotnet-from-env-without-fallback-test" { } '' 42 + ${appWithoutFallback}/bin/Application >"$out" 43 + ''); 44 + 45 + # NB assumes that without-fallback above to passes. 46 + use-dotnet-root-env = testers.testEqualContents { 47 + assertion = "buildDotnetModule uses DOTNET_ROOT from environment in wrapper"; 48 + expected = runtimeVersionFile; 49 + actual = runCommand "use-dotnet-from-env-root-test" { env.DOTNET_ROOT = dotnet-runtime; } '' 50 + ${appWithoutFallback}/bin/Application >"$out" 51 + ''; 52 + }; 53 + use-dotnet-path-env = testers.testEqualContents { 54 + assertion = "buildDotnetModule uses DOTNET_ROOT from dotnet in PATH in wrapper"; 55 + expected = runtimeVersionFile; 56 + actual = runCommand "use-dotnet-from-env-path-test" { dotnetRuntime = dotnet-runtime; } '' 57 + PATH=$dotnetRuntime''${PATH+:}$PATH ${appWithoutFallback}/bin/Application >"$out" 58 + ''; 59 + }; 60 + }
+5
pkgs/test/dotnet/use-dotnet-from-env/nuget-deps.nix
···
··· 1 + # This file was automatically generated by passthru.fetch-deps. 2 + # Please dont edit it manually, your changes might get overwritten! 3 + 4 + { fetchNuGet }: [ 5 + ]
+3
pkgs/test/dotnet/use-dotnet-from-env/src/Application.cs
···
··· 1 + using System; 2 + 3 + Console.Write(Environment.Version.ToString());
+5
pkgs/test/dotnet/use-dotnet-from-env/src/Application.csproj
···
··· 1 + <Project Sdk="Microsoft.NET.Sdk"> 2 + <PropertyGroup> 3 + <OutputType>exe</OutputType> 4 + </PropertyGroup> 5 + </Project>