Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 1ea48da

Browse files
author
jbeisner
committed
Run-Build.sh/ps1 does not behave correctly when passing in a target.
1 parent a212d5a commit 1ea48da

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

build/SandBoxAndPackage.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --configuration $(BuildConfiguration)</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
5252
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --docker $(DockerFolder)</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
5353
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --skip-prereqs</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
54-
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --generate-installers</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
54+
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) /t:GenerateInstallersAndCopyOutOfSandBox</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
5555
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) /p:RelativeSandBoxPackageOutputFolder=$(RelativeSandBoxPackageOutputFolder)</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
5656
<CommandExitCodeFirstTime>0</CommandExitCodeFirstTime>
5757
<PipeStderrToStdoutToCatchFirstFailure>2&gt;&amp;1</PipeStderrToStdoutToCatchFirstFailure>

run-build.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ if($Help)
2727
exit 0
2828
}
2929

30+
# The first 'pass' call to "dotnet msbuild build.proj" has a hard-coded "WriteDynamicPropsToStaticPropsFiles" target
31+
# therefore, this call should not have other targets defined. Remove all targets passed in as 'extra parameters'.
32+
$ExtraParametersNoTargets = ""
33+
foreach ($param in $ExtraParameters.split())
34+
{
35+
if(-Not ($param.StartsWith("/t:")))
36+
{
37+
$ExtraParametersNoTargets += " {0}" -f $param
38+
}
39+
}
40+
3041
$env:CONFIGURATION = $Configuration;
3142
$RepoRoot = "$PSScriptRoot"
3243
if(!$env:NUGET_PACKAGES){
@@ -86,7 +97,7 @@ if ($NoBuild)
8697
}
8798
else
8899
{
89-
dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $ExtraParameters
100+
dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $ExtraParametersNoTargets
90101
dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /p:Architecture=$Architecture $ExtraParameters
91102
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
92103
}

run-build.sh

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ source "$REPOROOT/scripts/common/_prettyprint.sh"
5858
BUILD=1
5959

6060
LINUX_PORTABLE_INSTALL_ARGS=
61-
ALL_LINUX_INSTALLERS_TARGET=
62-
GENERATE_INSTALLERS_TARGET=
6361
CUSTOM_BUILD_ARGS=
6462

6563
# Set nuget package cache under the repo
@@ -84,7 +82,7 @@ while [[ $# > 0 ]]; do
8482
--nobuild)
8583
BUILD=0
8684
;;
87-
--architecture)
85+
-a|--architecture)
8886
ARCHITECTURE=$2
8987
shift
9088
;;
@@ -100,31 +98,19 @@ while [[ $# > 0 ]]; do
10098
LINUX_PORTABLE_INSTALL_ARGS="--runtime-id linux-x64"
10199
CUSTOM_BUILD_ARGS="/p:Rid=\"linux-x64\" /p:OSName=\"linux\" /p:IslinuxPortable=\"true\""
102100
;;
103-
--all-linux-installers)
104-
ALL_LINUX_INSTALLERS_TARGET="/t:BuildAndPublishAllLinuxDistrosNativeInstallers"
105-
;;
106-
--generate-installers)
107-
GENERATE_INSTALLERS_TARGET="/t:GenerateInstallersAndCopyOutOfSandBox"
108-
;;
109101
--stage0)
110102
STAGE0_SOURCE_DIR=$2
111103
shift
112104
;;
113105
--help)
114-
echo "Usage: $0 [--configuration <CONFIGURATION>] [--skip-prereqs] [--nopackage] [--docker <IMAGENAME>] [--help]"
106+
echo "Usage: $0 [--configuration <CONFIGURATION>] [--architecture <ARCHITECTURE>] [--skip-prereqs] [--nopackage] [--nobuild ] [--help]"
115107
echo ""
116108
echo "Options:"
117109
echo " --configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
110+
echo " --architecture <ARCHITECTURE> Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)"
118111
echo " --skip-prereqs Skip checks for pre-reqs in dotnet_install"
119112
echo " --nopackage Skip packaging targets"
120113
echo " --nobuild Skip building, showing the command that would be used to build"
121-
echo " --docker <IMAGENAME> Build in Docker using the Dockerfile located in scripts/docker/IMAGENAME"
122-
echo " --linux-portable Builds the Linux portable .NET Tools instead of a distro-specific version."
123-
echo " --all-linux-installers Builds and publishes all the Linux distros' native installers; outer call"
124-
echo " Note: used primarily for 'AllLinuxDistrosNativeInstallers' VSO build."
125-
echo " --generate-installers Builds and publishes all the Linux distros' native installers; inner call"
126-
echo " Note: used primarily for 'AllLinuxDistrosNativeInstallers' VSO build."
127-
echo " --stage0 Set the stage0 source directory. The default is to download it from Azure."
128114
echo " --help Display this help message"
129115
exit 0
130116
;;
@@ -137,6 +123,15 @@ while [[ $# > 0 ]]; do
137123
shift
138124
done
139125

126+
# The first 'pass' call to "dotnet msbuild build.proj" has a hard-coded "WriteDynamicPropsToStaticPropsFiles" target
127+
# therefore, this call should not have other targets defined. Remove all targets passed in as 'extra parameters'.
128+
argsnotargets=( )
129+
for element in ${args[@]} do
130+
if [[ $element != /t:* ]]; then
131+
argsnotargets+=($element)
132+
fi
133+
done
134+
140135
# Create an install directory for the stage 0 CLI
141136
[ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_stage0/$ARCHITECTURE
142137
[ -d "$DOTNET_INSTALL_DIR" ] || mkdir -p $DOTNET_INSTALL_DIR
@@ -179,12 +174,10 @@ fi
179174
# Disable first run since we want to control all package sources
180175
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
181176

182-
echo "${args[@]}"
183-
184177
if [ $BUILD -eq 1 ]; then
185-
dotnet msbuild build.proj /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $args
186-
dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $ALL_LINUX_INSTALLERS_TARGET $GENERATE_INSTALLERS_TARGET $args
178+
dotnet msbuild build.proj /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $argsnotargets
179+
dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $args
187180
else
188181
echo "Not building due to --nobuild"
189-
echo "Command that would be run is: 'dotnet msbuild build.proj /m /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $ALL_LINUX_INSTALLERS_TARGET $GENERATE_INSTALLERS_TARGET $args'"
182+
echo "Command that would be run is: 'dotnet msbuild build.proj /m /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $args'"
190183
fi

0 commit comments

Comments
 (0)