From 5b462ef57a789729df844667d5257044688c6686 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 28 Oct 2024 22:00:57 -0300 Subject: [PATCH] buildDotnetModule: allow selfContainedBuild property to be omitted with null Fixes #351892 --- .../hooks/dotnet-build-hook.sh | 10 ++++++---- .../hooks/dotnet-configure-hook.sh | 10 ++++++---- .../hooks/dotnet-install-hook.sh | 16 +++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh index 08dbc41d0186..c45204c574de 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh @@ -27,10 +27,12 @@ dotnetBuildHook() { local -r parallelBuildFlag="false" fi - if [[ -n ${dotnetSelfContainedBuild-} ]]; then - dotnetBuildFlagsArray+=("-p:SelfContained=true") - else - dotnetBuildFlagsArray+=("-p:SelfContained=false") + if [[ -v dotnetSelfContainedBuild ]]; then + if [[ -n $dotnetSelfContainedBuild ]]; then + dotnetBuildFlagsArray+=("-p:SelfContained=true") + else + dotnetBuildFlagsArray+=("-p:SelfContained=false") + fi fi if [[ -n ${dotnetUseAppHost-} ]]; then diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh index aa7823331c42..542f0af79f63 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh @@ -24,10 +24,12 @@ dotnetConfigureHook() { local -r parallelFlag="--disable-parallel" fi - if [[ -n ${dotnetSelfContainedBuild-} ]]; then - dotnetRestoreFlagsArray+=("-p:SelfContained=true") - else - dotnetRestoreFlagsArray+=("-p:SelfContained=false") + if [[ -v dotnetSelfContainedBuild ]]; then + if [[ -n $dotnetSelfContainedBuild ]]; then + dotnetRestoreFlagsArray+=("-p:SelfContained=true") + else + dotnetRestoreFlagsArray+=("-p:SelfContained=false") + fi fi dotnetRestore() { diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh index 7b008a26d1c6..8b731b4feab1 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh @@ -20,13 +20,15 @@ dotnetInstallHook() { local dotnetRuntimeIdsArray=($dotnetRuntimeIds) fi - if [[ -n ${dotnetSelfContainedBuild-} ]]; then - dotnetInstallFlagsArray+=("--self-contained") - 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") + if [[ -v dotnetSelfContainedBuild ]]; then + if [[ -n $dotnetSelfContainedBuild ]]; then + dotnetInstallFlagsArray+=("--self-contained") + 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