nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
IvarWithoutBones 992b656c9e buildDotnetModule: use setup hooks
This is a much more flexible way of doing things, as we can adopt and
reuse these hooks for various tasks. Syntax highlighting now also works
way better for me, which is a nice bonus :)
2022-02-12 02:15:13 +01:00

41 lines
1.1 KiB
Bash

declare -a projectFile testProjectFile dotnetBuildFlags dotnetFlags
dotnetBuildHook() {
echo "Executing dotnetBuildHook"
runHook preBuild
if [ "${enableParallelBuilding-}" ]; then
maxCpuFlag="$NIX_BUILD_CORES"
parallelBuildFlag="true"
else
maxCpuFlag="1"
parallelBuildFlag="false"
fi
if [ "${version-}" ]; then
versionFlag="-p:Version=${version-}"
fi
for project in ${projectFile[@]} ${testProjectFile[@]}; do
env \
dotnet build "$project" \
-maxcpucount:$maxCpuFlag \
-p:BuildInParallel=$parallelBuildFlag \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
--configuration "@buildType@" \
--no-restore \
${versionFlag-} \
"${dotnetBuildFlags[@]}" \
"${dotnetFlags[@]}"
done
runHook postBuild
echo "Finished dotnetBuildHook"
}
if [[ -z "${dontDotnetBuild-}" && -z "${buildPhase-}" ]]; then
buildPhase=dotnetBuildHook
fi