dotnet-hook.sh: indent
This commit is contained in:
parent
e84eb87a63
commit
861ed441f6
@ -1,251 +1,251 @@
|
|||||||
dotnetConfigurePhase() {
|
dotnetConfigurePhase() {
|
||||||
echo "Executing dotnetConfigureHook"
|
echo "Executing dotnetConfigureHook"
|
||||||
|
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
|
|
||||||
if [[ -n $__structuredAttrs ]]; then
|
if [[ -n $__structuredAttrs ]]; then
|
||||||
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
||||||
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
|
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
|
||||||
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
|
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
|
||||||
local dotnetRestoreFlagsArray=( "${dotnetRestoreFlags[@]}" )
|
local dotnetRestoreFlagsArray=( "${dotnetRestoreFlags[@]}" )
|
||||||
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
||||||
|
else
|
||||||
|
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
||||||
|
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
|
||||||
|
local dotnetFlagsArray=($dotnetFlags)
|
||||||
|
local dotnetRestoreFlagsArray=($dotnetRestoreFlags)
|
||||||
|
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z ${enableParallelBuilding-} ]]; then
|
||||||
|
local -r parallelFlag="--disable-parallel"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -v dotnetSelfContainedBuild ]]; then
|
||||||
|
if [[ -n $dotnetSelfContainedBuild ]]; then
|
||||||
|
dotnetRestoreFlagsArray+=("-p:SelfContained=true")
|
||||||
else
|
else
|
||||||
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
dotnetRestoreFlagsArray+=("-p:SelfContained=false")
|
||||||
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
|
|
||||||
local dotnetFlagsArray=($dotnetFlags)
|
|
||||||
local dotnetRestoreFlagsArray=($dotnetRestoreFlags)
|
|
||||||
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z ${enableParallelBuilding-} ]]; then
|
dotnetRestore() {
|
||||||
local -r parallelFlag="--disable-parallel"
|
local -r projectFile="${1-}"
|
||||||
fi
|
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 [[ -v dotnetSelfContainedBuild ]]; then
|
if [[ -f .config/dotnet-tools.json || -f dotnet-tools.json ]]; then
|
||||||
if [[ -n $dotnetSelfContainedBuild ]]; then
|
dotnet tool restore
|
||||||
dotnetRestoreFlagsArray+=("-p:SelfContained=true")
|
fi
|
||||||
else
|
|
||||||
dotnetRestoreFlagsArray+=("-p:SelfContained=false")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
dotnetRestore() {
|
|
||||||
local -r projectFile="${1-}"
|
|
||||||
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
|
|
||||||
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. It’s 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 don’t 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=dotnetConfigurePhase
|
|
||||||
fi
|
|
||||||
|
|
||||||
dotnetBuildPhase() {
|
|
||||||
echo "Executing dotnetBuildHook"
|
|
||||||
|
|
||||||
runHook preBuild
|
|
||||||
|
|
||||||
local -r dotnetBuildType="${dotnetBuildType-Release}"
|
|
||||||
|
|
||||||
if [[ -n $__structuredAttrs ]]; then
|
|
||||||
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
|
||||||
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
|
|
||||||
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
|
|
||||||
local dotnetBuildFlagsArray=( "${dotnetBuildFlags[@]}" )
|
|
||||||
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
|
||||||
else
|
|
||||||
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
|
||||||
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
|
|
||||||
local dotnetFlagsArray=($dotnetFlags)
|
|
||||||
local dotnetBuildFlagsArray=($dotnetBuildFlags)
|
|
||||||
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "${enableParallelBuilding-}" ]]; then
|
|
||||||
local -r maxCpuFlag="$NIX_BUILD_CORES"
|
|
||||||
local -r parallelBuildFlag="true"
|
|
||||||
else
|
|
||||||
local -r maxCpuFlag="1"
|
|
||||||
local -r parallelBuildFlag="false"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -v dotnetSelfContainedBuild ]]; then
|
|
||||||
if [[ -n $dotnetSelfContainedBuild ]]; then
|
|
||||||
dotnetBuildFlagsArray+=("-p:SelfContained=true")
|
|
||||||
else
|
|
||||||
dotnetBuildFlagsArray+=("-p:SelfContained=false")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n ${dotnetUseAppHost-} ]]; then
|
|
||||||
dotnetBuildFlagsArray+=("-p:UseAppHost=true")
|
|
||||||
fi
|
|
||||||
|
|
||||||
local versionFlagsArray=()
|
|
||||||
if [[ -n ${version-} ]]; then
|
|
||||||
versionFlagsArray+=("-p:InformationalVersion=$version")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n ${versionForDotnet-} ]]; then
|
|
||||||
versionFlagsArray+=("-p:Version=$versionForDotnet")
|
|
||||||
fi
|
|
||||||
|
|
||||||
dotnetBuild() {
|
|
||||||
local -r projectFile="${1-}"
|
|
||||||
|
|
||||||
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
|
|
||||||
local runtimeIdFlagsArray=()
|
|
||||||
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
|
|
||||||
runtimeIdFlagsArray+=("--runtime" "$runtimeId")
|
|
||||||
fi
|
|
||||||
|
|
||||||
dotnet build ${1+"$projectFile"} \
|
|
||||||
-maxcpucount:"$maxCpuFlag" \
|
|
||||||
-p:BuildInParallel="$parallelBuildFlag" \
|
|
||||||
-p:ContinuousIntegrationBuild=true \
|
|
||||||
-p:Deterministic=true \
|
|
||||||
-p:OverwriteReadOnlyFiles=true \
|
|
||||||
--configuration "$dotnetBuildType" \
|
|
||||||
--no-restore \
|
|
||||||
"${versionFlagsArray[@]}" \
|
|
||||||
"${runtimeIdFlagsArray[@]}" \
|
|
||||||
"${dotnetBuildFlagsArray[@]}" \
|
|
||||||
"${dotnetFlagsArray[@]}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
# 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. It’s 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 don’t have
|
||||||
|
# projects.
|
||||||
|
if [[ -z ${dotnetGlobalTool-} ]]; then
|
||||||
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
|
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
|
||||||
dotnetBuild
|
dotnetRestore
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local projectFile
|
local projectFile
|
||||||
for projectFile in "${dotnetProjectFilesArray[@]}" "${dotnetTestProjectFilesArray[@]}"; do
|
for projectFile in "${dotnetProjectFilesArray[@]}" "${dotnetTestProjectFilesArray[@]}"; do
|
||||||
dotnetBuild "$projectFile"
|
dotnetRestore "$projectFile"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postBuild
|
runHook postConfigure
|
||||||
|
|
||||||
echo "Finished dotnetBuildHook"
|
echo "Finished dotnetConfigureHook"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -z "${dontDotnetConfigure-}" && -z "${configurePhase-}" ]]; then
|
||||||
|
configurePhase=dotnetConfigurePhase
|
||||||
|
fi
|
||||||
|
|
||||||
|
dotnetBuildPhase() {
|
||||||
|
echo "Executing dotnetBuildHook"
|
||||||
|
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
local -r dotnetBuildType="${dotnetBuildType-Release}"
|
||||||
|
|
||||||
|
if [[ -n $__structuredAttrs ]]; then
|
||||||
|
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
||||||
|
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
|
||||||
|
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
|
||||||
|
local dotnetBuildFlagsArray=( "${dotnetBuildFlags[@]}" )
|
||||||
|
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
||||||
|
else
|
||||||
|
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
||||||
|
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
|
||||||
|
local dotnetFlagsArray=($dotnetFlags)
|
||||||
|
local dotnetBuildFlagsArray=($dotnetBuildFlags)
|
||||||
|
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${enableParallelBuilding-}" ]]; then
|
||||||
|
local -r maxCpuFlag="$NIX_BUILD_CORES"
|
||||||
|
local -r parallelBuildFlag="true"
|
||||||
|
else
|
||||||
|
local -r maxCpuFlag="1"
|
||||||
|
local -r parallelBuildFlag="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -v dotnetSelfContainedBuild ]]; then
|
||||||
|
if [[ -n $dotnetSelfContainedBuild ]]; then
|
||||||
|
dotnetBuildFlagsArray+=("-p:SelfContained=true")
|
||||||
|
else
|
||||||
|
dotnetBuildFlagsArray+=("-p:SelfContained=false")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${dotnetUseAppHost-} ]]; then
|
||||||
|
dotnetBuildFlagsArray+=("-p:UseAppHost=true")
|
||||||
|
fi
|
||||||
|
|
||||||
|
local versionFlagsArray=()
|
||||||
|
if [[ -n ${version-} ]]; then
|
||||||
|
versionFlagsArray+=("-p:InformationalVersion=$version")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${versionForDotnet-} ]]; then
|
||||||
|
versionFlagsArray+=("-p:Version=$versionForDotnet")
|
||||||
|
fi
|
||||||
|
|
||||||
|
dotnetBuild() {
|
||||||
|
local -r projectFile="${1-}"
|
||||||
|
|
||||||
|
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
|
||||||
|
local runtimeIdFlagsArray=()
|
||||||
|
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
|
||||||
|
runtimeIdFlagsArray+=("--runtime" "$runtimeId")
|
||||||
|
fi
|
||||||
|
|
||||||
|
dotnet build ${1+"$projectFile"} \
|
||||||
|
-maxcpucount:"$maxCpuFlag" \
|
||||||
|
-p:BuildInParallel="$parallelBuildFlag" \
|
||||||
|
-p:ContinuousIntegrationBuild=true \
|
||||||
|
-p:Deterministic=true \
|
||||||
|
-p:OverwriteReadOnlyFiles=true \
|
||||||
|
--configuration "$dotnetBuildType" \
|
||||||
|
--no-restore \
|
||||||
|
"${versionFlagsArray[@]}" \
|
||||||
|
"${runtimeIdFlagsArray[@]}" \
|
||||||
|
"${dotnetBuildFlagsArray[@]}" \
|
||||||
|
"${dotnetFlagsArray[@]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
|
||||||
|
dotnetBuild
|
||||||
|
fi
|
||||||
|
|
||||||
|
local projectFile
|
||||||
|
for projectFile in "${dotnetProjectFilesArray[@]}" "${dotnetTestProjectFilesArray[@]}"; do
|
||||||
|
dotnetBuild "$projectFile"
|
||||||
|
done
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
|
||||||
|
echo "Finished dotnetBuildHook"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z ${dontDotnetBuild-} && -z ${buildPhase-} ]]; then
|
if [[ -z ${dontDotnetBuild-} && -z ${buildPhase-} ]]; then
|
||||||
buildPhase=dotnetBuildPhase
|
buildPhase=dotnetBuildPhase
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dotnetCheckPhase() {
|
dotnetCheckPhase() {
|
||||||
echo "Executing dotnetCheckHook"
|
echo "Executing dotnetCheckHook"
|
||||||
|
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
|
|
||||||
local -r dotnetBuildType="${dotnetBuildType-Release}"
|
local -r dotnetBuildType="${dotnetBuildType-Release}"
|
||||||
|
|
||||||
if [[ -n $__structuredAttrs ]]; then
|
if [[ -n $__structuredAttrs ]]; then
|
||||||
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
||||||
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
|
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
|
||||||
local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" )
|
local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" )
|
||||||
local dotnetTestFiltersArray=( "${dotnetTestFilters[@]}" )
|
local dotnetTestFiltersArray=( "${dotnetTestFilters[@]}" )
|
||||||
local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" )
|
local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" )
|
||||||
local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
|
local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
|
||||||
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
||||||
else
|
else
|
||||||
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
||||||
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
|
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
|
||||||
local dotnetTestFlagsArray=($dotnetTestFlags)
|
local dotnetTestFlagsArray=($dotnetTestFlags)
|
||||||
local dotnetTestFiltersArray=($dotnetTestFilters)
|
local dotnetTestFiltersArray=($dotnetTestFilters)
|
||||||
local dotnetDisabledTestsArray=($dotnetDisabledTests)
|
local dotnetDisabledTestsArray=($dotnetDisabledTests)
|
||||||
local dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
|
local dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
|
||||||
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then
|
if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then
|
||||||
local disabledTestsFilters=("${dotnetDisabledTestsArray[@]/#/FullyQualifiedName!=}")
|
local disabledTestsFilters=("${dotnetDisabledTestsArray[@]/#/FullyQualifiedName!=}")
|
||||||
dotnetTestFiltersArray=( "${dotnetTestFiltersArray[@]}" "${disabledTestsFilters[@]//,/%2C}" )
|
dotnetTestFiltersArray=( "${dotnetTestFiltersArray[@]}" "${disabledTestsFilters[@]//,/%2C}" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( ${#dotnetTestFiltersArray[@]} > 0 )); then
|
if (( ${#dotnetTestFiltersArray[@]} > 0 )); then
|
||||||
local OLDIFS="$IFS" IFS='&'
|
local OLDIFS="$IFS" IFS='&'
|
||||||
dotnetTestFlagsArray+=("--filter:${dotnetTestFiltersArray[*]}")
|
dotnetTestFlagsArray+=("--filter:${dotnetTestFiltersArray[*]}")
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local libraryPath="${LD_LIBRARY_PATH-}"
|
local libraryPath="${LD_LIBRARY_PATH-}"
|
||||||
if (( ${#dotnetRuntimeDepsArray[@]} > 0 )); then
|
if (( ${#dotnetRuntimeDepsArray[@]} > 0 )); then
|
||||||
local libraryPathArray=("${dotnetRuntimeDepsArray[@]/%//lib}")
|
local libraryPathArray=("${dotnetRuntimeDepsArray[@]/%//lib}")
|
||||||
local OLDIFS="$IFS" IFS=':'
|
local OLDIFS="$IFS" IFS=':'
|
||||||
libraryPath="${libraryPathArray[*]}${libraryPath:+':'}$libraryPath"
|
libraryPath="${libraryPathArray[*]}${libraryPath:+':'}$libraryPath"
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${enableParallelBuilding-} ]]; then
|
if [[ -n ${enableParallelBuilding-} ]]; then
|
||||||
local -r maxCpuFlag="$NIX_BUILD_CORES"
|
local -r maxCpuFlag="$NIX_BUILD_CORES"
|
||||||
else
|
else
|
||||||
local -r maxCpuFlag="1"
|
local -r maxCpuFlag="1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local projectFile runtimeId
|
local projectFile runtimeId
|
||||||
for projectFile in "${dotnetTestProjectFilesArray[@]-${dotnetProjectFilesArray[@]}}"; do
|
for projectFile in "${dotnetTestProjectFilesArray[@]-${dotnetProjectFilesArray[@]}}"; do
|
||||||
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
|
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
|
||||||
local runtimeIdFlagsArray=()
|
local runtimeIdFlagsArray=()
|
||||||
if [[ $projectFile == *.csproj ]]; then
|
if [[ $projectFile == *.csproj ]]; then
|
||||||
runtimeIdFlagsArray=("--runtime" "$runtimeId")
|
runtimeIdFlagsArray=("--runtime" "$runtimeId")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LD_LIBRARY_PATH=$libraryPath \
|
LD_LIBRARY_PATH=$libraryPath \
|
||||||
dotnet test "$projectFile" \
|
dotnet test "$projectFile" \
|
||||||
-maxcpucount:"$maxCpuFlag" \
|
-maxcpucount:"$maxCpuFlag" \
|
||||||
-p:ContinuousIntegrationBuild=true \
|
-p:ContinuousIntegrationBuild=true \
|
||||||
-p:Deterministic=true \
|
-p:Deterministic=true \
|
||||||
--configuration "$dotnetBuildType" \
|
--configuration "$dotnetBuildType" \
|
||||||
--no-restore \
|
--no-restore \
|
||||||
--no-build \
|
--no-build \
|
||||||
--logger "console;verbosity=normal" \
|
--logger "console;verbosity=normal" \
|
||||||
"${runtimeIdFlagsArray[@]}" \
|
"${runtimeIdFlagsArray[@]}" \
|
||||||
"${dotnetTestFlagsArray[@]}" \
|
"${dotnetTestFlagsArray[@]}" \
|
||||||
"${dotnetFlagsArray[@]}"
|
"${dotnetFlagsArray[@]}"
|
||||||
done
|
|
||||||
done
|
done
|
||||||
|
done
|
||||||
|
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
|
|
||||||
echo "Finished dotnetCheckHook"
|
echo "Finished dotnetCheckHook"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z "${dontDotnetCheck-}" && -z "${checkPhase-}" ]]; then
|
if [[ -z "${dontDotnetCheck-}" && -z "${checkPhase-}" ]]; then
|
||||||
checkPhase=dotnetCheckPhase
|
checkPhase=dotnetCheckPhase
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For compatibility, convert makeWrapperArgs to an array unless we are using
|
# For compatibility, convert makeWrapperArgs to an array unless we are using
|
||||||
@ -254,16 +254,16 @@ fi
|
|||||||
# See https://github.com/NixOS/nixpkgs/blob/858f4db3048c5be3527e183470e93c1a72c5727c/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh#L1-L3
|
# See https://github.com/NixOS/nixpkgs/blob/858f4db3048c5be3527e183470e93c1a72c5727c/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh#L1-L3
|
||||||
# and https://github.com/NixOS/nixpkgs/pull/313005#issuecomment-2175482920
|
# and https://github.com/NixOS/nixpkgs/pull/313005#issuecomment-2175482920
|
||||||
if [[ -z $__structuredAttrs ]]; then
|
if [[ -z $__structuredAttrs ]]; then
|
||||||
makeWrapperArgs=( ${makeWrapperArgs-} )
|
makeWrapperArgs=( ${makeWrapperArgs-} )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# First argument is the executable you want to wrap,
|
# First argument is the executable you want to wrap,
|
||||||
# the second is the destination for the wrapper.
|
# the second is the destination for the wrapper.
|
||||||
wrapDotnetProgram() {
|
wrapDotnetProgram() {
|
||||||
local -r dotnetRuntime=@dotnetRuntime@
|
local -r dotnetRuntime=@dotnetRuntime@
|
||||||
local -r wrapperPath=@wrapperPath@
|
local -r wrapperPath=@wrapperPath@
|
||||||
|
|
||||||
local -r dotnetFromEnvScript='dotnetFromEnv() {
|
local -r dotnetFromEnvScript='dotnetFromEnv() {
|
||||||
local dotnetPath
|
local dotnetPath
|
||||||
if command -v dotnet 2>&1 >/dev/null; then
|
if command -v dotnet 2>&1 >/dev/null; then
|
||||||
dotnetPath=$(which dotnet) && \
|
dotnetPath=$(which dotnet) && \
|
||||||
@ -274,193 +274,193 @@ wrapDotnetProgram() {
|
|||||||
}
|
}
|
||||||
dotnetFromEnv'
|
dotnetFromEnv'
|
||||||
|
|
||||||
if [[ -n $__structuredAttrs ]]; then
|
if [[ -n $__structuredAttrs ]]; then
|
||||||
local -r dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
|
local -r dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
|
||||||
else
|
else
|
||||||
local -r dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
|
local -r dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
|
||||||
|
fi
|
||||||
|
|
||||||
|
local dotnetRuntimeDepsFlags=()
|
||||||
|
if (( ${#dotnetRuntimeDepsArray[@]} > 0 )); then
|
||||||
|
local libraryPathArray=("${dotnetRuntimeDepsArray[@]/%//lib}")
|
||||||
|
local OLDIFS="$IFS" IFS=':'
|
||||||
|
dotnetRuntimeDepsFlags+=("--suffix" "LD_LIBRARY_PATH" ":" "${libraryPathArray[*]}")
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local dotnetRootFlagsArray=()
|
||||||
|
if [[ -z ${dotnetSelfContainedBuild-} ]]; then
|
||||||
|
if [[ -n ${useDotnetFromEnv-} ]]; then
|
||||||
|
# if dotnet CLI is available, set DOTNET_ROOT based on it. Otherwise set to default .NET runtime
|
||||||
|
dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$wrapperPath")
|
||||||
|
dotnetRootFlagsArray+=("--run" "$dotnetFromEnvScript")
|
||||||
|
if [[ -n $dotnetRuntime ]]; then
|
||||||
|
dotnetRootFlagsArray+=("--set-default" "DOTNET_ROOT" "$dotnetRuntime/share/dotnet")
|
||||||
|
dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$dotnetRuntime/bin")
|
||||||
|
fi
|
||||||
|
elif [[ -n $dotnetRuntime ]]; then
|
||||||
|
dotnetRootFlagsArray+=("--set" "DOTNET_ROOT" "$dotnetRuntime/share/dotnet")
|
||||||
|
dotnetRootFlagsArray+=("--prefix" "PATH" ":" "$dotnetRuntime/bin")
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
local dotnetRuntimeDepsFlags=()
|
makeWrapper "$1" "$2" \
|
||||||
if (( ${#dotnetRuntimeDepsArray[@]} > 0 )); then
|
"${dotnetRuntimeDepsFlags[@]}" \
|
||||||
local libraryPathArray=("${dotnetRuntimeDepsArray[@]/%//lib}")
|
"${dotnetRootFlagsArray[@]}" \
|
||||||
local OLDIFS="$IFS" IFS=':'
|
"${gappsWrapperArgs[@]}" \
|
||||||
dotnetRuntimeDepsFlags+=("--suffix" "LD_LIBRARY_PATH" ":" "${libraryPathArray[*]}")
|
"${makeWrapperArgs[@]}"
|
||||||
IFS="$OLDIFS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local dotnetRootFlagsArray=()
|
echo "installed wrapper to "$2""
|
||||||
if [[ -z ${dotnetSelfContainedBuild-} ]]; then
|
|
||||||
if [[ -n ${useDotnetFromEnv-} ]]; then
|
|
||||||
# if dotnet CLI is available, set DOTNET_ROOT based on it. Otherwise set to default .NET runtime
|
|
||||||
dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$wrapperPath")
|
|
||||||
dotnetRootFlagsArray+=("--run" "$dotnetFromEnvScript")
|
|
||||||
if [[ -n $dotnetRuntime ]]; then
|
|
||||||
dotnetRootFlagsArray+=("--set-default" "DOTNET_ROOT" "$dotnetRuntime/share/dotnet")
|
|
||||||
dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$dotnetRuntime/bin")
|
|
||||||
fi
|
|
||||||
elif [[ -n $dotnetRuntime ]]; then
|
|
||||||
dotnetRootFlagsArray+=("--set" "DOTNET_ROOT" "$dotnetRuntime/share/dotnet")
|
|
||||||
dotnetRootFlagsArray+=("--prefix" "PATH" ":" "$dotnetRuntime/bin")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
makeWrapper "$1" "$2" \
|
|
||||||
"${dotnetRuntimeDepsFlags[@]}" \
|
|
||||||
"${dotnetRootFlagsArray[@]}" \
|
|
||||||
"${gappsWrapperArgs[@]}" \
|
|
||||||
"${makeWrapperArgs[@]}"
|
|
||||||
|
|
||||||
echo "installed wrapper to "$2""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dotnetFixupPhase() {
|
dotnetFixupPhase() {
|
||||||
local -r dotnetInstallPath="${dotnetInstallPath-$out/lib/$pname}"
|
local -r dotnetInstallPath="${dotnetInstallPath-$out/lib/$pname}"
|
||||||
|
|
||||||
local executable executableBasename
|
local executable executableBasename
|
||||||
|
|
||||||
# check if dotnetExecutables is declared (including empty values, in which case we generate no executables)
|
# check if dotnetExecutables is declared (including empty values, in which case we generate no executables)
|
||||||
if declare -p dotnetExecutables &>/dev/null; then
|
if declare -p dotnetExecutables &>/dev/null; then
|
||||||
if [[ -n $__structuredAttrs ]]; then
|
if [[ -n $__structuredAttrs ]]; then
|
||||||
local dotnetExecutablesArray=( "${dotnetExecutables[@]}" )
|
local dotnetExecutablesArray=( "${dotnetExecutables[@]}" )
|
||||||
else
|
|
||||||
local dotnetExecutablesArray=($dotnetExecutables)
|
|
||||||
fi
|
|
||||||
for executable in "${dotnetExecutablesArray[@]}"; do
|
|
||||||
executableBasename=$(basename "$executable")
|
|
||||||
|
|
||||||
local path="$dotnetInstallPath/$executable"
|
|
||||||
|
|
||||||
if test -x "$path"; then
|
|
||||||
wrapDotnetProgram "$path" "$out/bin/$executableBasename"
|
|
||||||
else
|
|
||||||
echo "Specified binary \"$executable\" is either not an executable or does not exist!"
|
|
||||||
echo "Looked in $path"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
while IFS= read -d '' executable; do
|
local dotnetExecutablesArray=($dotnetExecutables)
|
||||||
executableBasename=$(basename "$executable")
|
|
||||||
wrapDotnetProgram "$executable" "$out/bin/$executableBasename" \;
|
|
||||||
done < <(find "$dotnetInstallPath" ! -name "*.dll" -executable -type f -print0)
|
|
||||||
fi
|
fi
|
||||||
|
for executable in "${dotnetExecutablesArray[@]}"; do
|
||||||
|
executableBasename=$(basename "$executable")
|
||||||
|
|
||||||
|
local path="$dotnetInstallPath/$executable"
|
||||||
|
|
||||||
|
if test -x "$path"; then
|
||||||
|
wrapDotnetProgram "$path" "$out/bin/$executableBasename"
|
||||||
|
else
|
||||||
|
echo "Specified binary \"$executable\" is either not an executable or does not exist!"
|
||||||
|
echo "Looked in $path"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
while IFS= read -d '' executable; do
|
||||||
|
executableBasename=$(basename "$executable")
|
||||||
|
wrapDotnetProgram "$executable" "$out/bin/$executableBasename" \;
|
||||||
|
done < <(find "$dotnetInstallPath" ! -name "*.dll" -executable -type f -print0)
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z "${dontFixup-}" && -z "${dontDotnetFixup-}" ]]; then
|
if [[ -z "${dontFixup-}" && -z "${dontDotnetFixup-}" ]]; then
|
||||||
appendToVar preFixupPhases dotnetFixupPhase
|
appendToVar preFixupPhases dotnetFixupPhase
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dotnetInstallPhase() {
|
dotnetInstallPhase() {
|
||||||
echo "Executing dotnetInstallHook"
|
echo "Executing dotnetInstallHook"
|
||||||
|
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
local -r dotnetInstallPath="${dotnetInstallPath-$out/lib/$pname}"
|
local -r dotnetInstallPath="${dotnetInstallPath-$out/lib/$pname}"
|
||||||
local -r dotnetBuildType="${dotnetBuildType-Release}"
|
local -r dotnetBuildType="${dotnetBuildType-Release}"
|
||||||
|
|
||||||
if [[ -n $__structuredAttrs ]]; then
|
if [[ -n $__structuredAttrs ]]; then
|
||||||
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
||||||
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
|
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
|
||||||
local dotnetInstallFlagsArray=( "${dotnetInstallFlags[@]}" )
|
local dotnetInstallFlagsArray=( "${dotnetInstallFlags[@]}" )
|
||||||
local dotnetPackFlagsArray=( "${dotnetPackFlags[@]}" )
|
local dotnetPackFlagsArray=( "${dotnetPackFlags[@]}" )
|
||||||
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
||||||
|
else
|
||||||
|
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
||||||
|
local dotnetFlagsArray=($dotnetFlags)
|
||||||
|
local dotnetInstallFlagsArray=($dotnetInstallFlags)
|
||||||
|
local dotnetPackFlagsArray=($dotnetPackFlags)
|
||||||
|
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -v dotnetSelfContainedBuild ]]; then
|
||||||
|
if [[ -n $dotnetSelfContainedBuild ]]; then
|
||||||
|
dotnetInstallFlagsArray+=("--self-contained")
|
||||||
else
|
else
|
||||||
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
dotnetInstallFlagsArray+=("--no-self-contained")
|
||||||
local dotnetFlagsArray=($dotnetFlags)
|
# https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained
|
||||||
local dotnetInstallFlagsArray=($dotnetInstallFlags)
|
# Trimming is only available for self-contained build, so force disable it here
|
||||||
local dotnetPackFlagsArray=($dotnetPackFlags)
|
dotnetInstallFlagsArray+=("-p:PublishTrimmed=false")
|
||||||
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -v dotnetSelfContainedBuild ]]; then
|
if [[ -n ${dotnetUseAppHost-} ]]; then
|
||||||
if [[ -n $dotnetSelfContainedBuild ]]; then
|
dotnetInstallFlagsArray+=("-p:UseAppHost=true")
|
||||||
dotnetInstallFlagsArray+=("--self-contained")
|
fi
|
||||||
else
|
|
||||||
dotnetInstallFlagsArray+=("--no-self-contained")
|
|
||||||
# https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained
|
|
||||||
# Trimming is only available for self-contained build, so force disable it here
|
|
||||||
dotnetInstallFlagsArray+=("-p:PublishTrimmed=false")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n ${dotnetUseAppHost-} ]]; then
|
if [[ -n ${enableParallelBuilding-} ]]; then
|
||||||
dotnetInstallFlagsArray+=("-p:UseAppHost=true")
|
local -r maxCpuFlag="$NIX_BUILD_CORES"
|
||||||
fi
|
else
|
||||||
|
local -r maxCpuFlag="1"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n ${enableParallelBuilding-} ]]; then
|
dotnetPublish() {
|
||||||
local -r maxCpuFlag="$NIX_BUILD_CORES"
|
local -r projectFile="${1-}"
|
||||||
else
|
|
||||||
local -r maxCpuFlag="1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
dotnetPublish() {
|
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
|
||||||
local -r projectFile="${1-}"
|
runtimeIdFlagsArray=()
|
||||||
|
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
|
||||||
|
runtimeIdFlagsArray+=("--runtime" "$runtimeId")
|
||||||
|
fi
|
||||||
|
|
||||||
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
|
dotnet publish ${1+"$projectFile"} \
|
||||||
runtimeIdFlagsArray=()
|
-maxcpucount:"$maxCpuFlag" \
|
||||||
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
|
-p:ContinuousIntegrationBuild=true \
|
||||||
runtimeIdFlagsArray+=("--runtime" "$runtimeId")
|
-p:Deterministic=true \
|
||||||
fi
|
-p:OverwriteReadOnlyFiles=true \
|
||||||
|
--output "$dotnetInstallPath" \
|
||||||
|
--configuration "$dotnetBuildType" \
|
||||||
|
--no-restore \
|
||||||
|
--no-build \
|
||||||
|
"${runtimeIdFlagsArray[@]}" \
|
||||||
|
"${dotnetInstallFlagsArray[@]}" \
|
||||||
|
"${dotnetFlagsArray[@]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
dotnet publish ${1+"$projectFile"} \
|
dotnetPack() {
|
||||||
-maxcpucount:"$maxCpuFlag" \
|
local -r projectFile="${1-}"
|
||||||
-p:ContinuousIntegrationBuild=true \
|
|
||||||
-p:Deterministic=true \
|
|
||||||
-p:OverwriteReadOnlyFiles=true \
|
|
||||||
--output "$dotnetInstallPath" \
|
|
||||||
--configuration "$dotnetBuildType" \
|
|
||||||
--no-restore \
|
|
||||||
--no-build \
|
|
||||||
"${runtimeIdFlagsArray[@]}" \
|
|
||||||
"${dotnetInstallFlagsArray[@]}" \
|
|
||||||
"${dotnetFlagsArray[@]}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
dotnetPack() {
|
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
|
||||||
local -r projectFile="${1-}"
|
dotnet pack ${1+"$projectFile"} \
|
||||||
|
-maxcpucount:"$maxCpuFlag" \
|
||||||
|
-p:ContinuousIntegrationBuild=true \
|
||||||
|
-p:Deterministic=true \
|
||||||
|
-p:OverwriteReadOnlyFiles=true \
|
||||||
|
--output "$out/share/nuget/source" \
|
||||||
|
--configuration "$dotnetBuildType" \
|
||||||
|
--no-restore \
|
||||||
|
--no-build \
|
||||||
|
--runtime "$runtimeId" \
|
||||||
|
"${dotnetPackFlagsArray[@]}" \
|
||||||
|
"${dotnetFlagsArray[@]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
|
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
|
||||||
dotnet pack ${1+"$projectFile"} \
|
dotnetPublish
|
||||||
-maxcpucount:"$maxCpuFlag" \
|
else
|
||||||
-p:ContinuousIntegrationBuild=true \
|
local projectFile
|
||||||
-p:Deterministic=true \
|
for projectFile in "${dotnetProjectFilesArray[@]}"; do
|
||||||
-p:OverwriteReadOnlyFiles=true \
|
dotnetPublish "$projectFile"
|
||||||
--output "$out/share/nuget/source" \
|
done
|
||||||
--configuration "$dotnetBuildType" \
|
fi
|
||||||
--no-restore \
|
|
||||||
--no-build \
|
|
||||||
--runtime "$runtimeId" \
|
|
||||||
"${dotnetPackFlagsArray[@]}" \
|
|
||||||
"${dotnetFlagsArray[@]}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if [[ -n ${packNupkg-} ]]; then
|
||||||
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
|
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
|
||||||
dotnetPublish
|
dotnetPack
|
||||||
else
|
else
|
||||||
local projectFile
|
local projectFile
|
||||||
for projectFile in "${dotnetProjectFilesArray[@]}"; do
|
for projectFile in "${dotnetProjectFilesArray[@]}"; do
|
||||||
dotnetPublish "$projectFile"
|
dotnetPack "$projectFile"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n ${packNupkg-} ]]; then
|
runHook postInstall
|
||||||
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
|
|
||||||
dotnetPack
|
|
||||||
else
|
|
||||||
local projectFile
|
|
||||||
for projectFile in "${dotnetProjectFilesArray[@]}"; do
|
|
||||||
dotnetPack "$projectFile"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
runHook postInstall
|
echo "Finished dotnetInstallHook"
|
||||||
|
|
||||||
echo "Finished dotnetInstallHook"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z "${dontDotnetInstall-}" && -z "${installPhase-}" ]]; then
|
if [[ -z "${dontDotnetInstall-}" && -z "${installPhase-}" ]]; then
|
||||||
installPhase=dotnetInstallPhase
|
installPhase=dotnetInstallPhase
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user