0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 22:20:30 +03:00
nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.7 KiB
Bash
Raw Normal View History

dotnetConfigureHook() {
echo "Executing dotnetConfigureHook"
runHook preConfigure
local -r dynamicLinker=@dynamicLinker@
local -r libPath=@libPath@
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
local dotnetRestoreFlagsArray=( "${dotnetRestoreFlags[@]}" )
2024-06-15 16:53:16 -03:00
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
local dotnetFlagsArray=($dotnetFlags)
local dotnetRestoreFlagsArray=($dotnetRestoreFlags)
2024-06-15 16:53:16 -03:00
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
fi
if [[ -z ${enableParallelBuilding-} ]]; then
local -r parallelFlag="--disable-parallel"
fi
if [[ -n ${dotnetSelfContainedBuild-} ]]; then
dotnetRestoreFlagsArray+=("-p:SelfContained=true")
else
dotnetRestoreFlagsArray+=("-p:SelfContained=false")
fi
dotnetRestore() {
local -r projectFile="${1-}"
2024-06-15 16:53:16 -03:00
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
dotnet restore ${1+"$projectFile"} \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
-p:NuGetAudit=false \
--runtime "$runtimeId" \
${parallelFlag-} \
"${dotnetRestoreFlagsArray[@]}" \
"${dotnetFlagsArray[@]}"
done
}
if [[ -f .config/dotnet-tools.json || -f dotnet-tools.json ]]; then
2024-06-15 16:53:16 -03:00
dotnet tool restore
fi
# dotnetGlobalTool is set in buildDotnetGlobalTool to patch dependencies but
# avoid other project-specific logic. This is a hack, but the old behavior
# is worse as it relied on a bug: setting projectFile to an empty string
# made the hooks actually skip all project-specific logic. Its hard to keep
# backwards compatibility with this odd behavior now since we are using
# arrays, so instead we just pass a variable to indicate that we dont have
# projects.
if [[ -z ${dotnetGlobalTool-} ]]; then
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
dotnetRestore
fi
local projectFile
for projectFile in "${dotnetProjectFilesArray[@]}" "${dotnetTestProjectFilesArray[@]}"; do
dotnetRestore "$projectFile"
done
fi
runHook postConfigure
echo "Finished dotnetConfigureHook"
}
if [[ -z "${dontDotnetConfigure-}" && -z "${configurePhase-}" ]]; then
configurePhase=dotnetConfigureHook
fi