Run-Build.sh/ps1 does not behave correctly when passing in a target.

This commit is contained in:
jbeisner 2018-01-11 21:23:46 +00:00
parent a212d5a017
commit 1ea48da27c
3 changed files with 28 additions and 24 deletions

View file

@ -51,7 +51,7 @@
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --configuration $(BuildConfiguration)</CommandToInvokeBuildScriptInDockerToPackageInSandBox> <CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --configuration $(BuildConfiguration)</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --docker $(DockerFolder)</CommandToInvokeBuildScriptInDockerToPackageInSandBox> <CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --docker $(DockerFolder)</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --skip-prereqs</CommandToInvokeBuildScriptInDockerToPackageInSandBox> <CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --skip-prereqs</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) --generate-installers</CommandToInvokeBuildScriptInDockerToPackageInSandBox> <CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) /t:GenerateInstallersAndCopyOutOfSandBox</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
<CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) /p:RelativeSandBoxPackageOutputFolder=$(RelativeSandBoxPackageOutputFolder)</CommandToInvokeBuildScriptInDockerToPackageInSandBox> <CommandToInvokeBuildScriptInDockerToPackageInSandBox>$(CommandToInvokeBuildScriptInDockerToPackageInSandBox) /p:RelativeSandBoxPackageOutputFolder=$(RelativeSandBoxPackageOutputFolder)</CommandToInvokeBuildScriptInDockerToPackageInSandBox>
<CommandExitCodeFirstTime>0</CommandExitCodeFirstTime> <CommandExitCodeFirstTime>0</CommandExitCodeFirstTime>
<PipeStderrToStdoutToCatchFirstFailure>2&gt;&amp;1</PipeStderrToStdoutToCatchFirstFailure> <PipeStderrToStdoutToCatchFirstFailure>2&gt;&amp;1</PipeStderrToStdoutToCatchFirstFailure>

View file

@ -27,6 +27,17 @@ if($Help)
exit 0 exit 0
} }
# The first 'pass' call to "dotnet msbuild build.proj" has a hard-coded "WriteDynamicPropsToStaticPropsFiles" target
# therefore, this call should not have other targets defined. Remove all targets passed in as 'extra parameters'.
$ExtraParametersNoTargets = ""
foreach ($param in $ExtraParameters.split())
{
if(-Not ($param.StartsWith("/t:")))
{
$ExtraParametersNoTargets += " {0}" -f $param
}
}
$env:CONFIGURATION = $Configuration; $env:CONFIGURATION = $Configuration;
$RepoRoot = "$PSScriptRoot" $RepoRoot = "$PSScriptRoot"
if(!$env:NUGET_PACKAGES){ if(!$env:NUGET_PACKAGES){
@ -86,7 +97,7 @@ if ($NoBuild)
} }
else else
{ {
dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $ExtraParameters dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $ExtraParametersNoTargets
dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /p:Architecture=$Architecture $ExtraParameters dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /p:Architecture=$Architecture $ExtraParameters
if($LASTEXITCODE -ne 0) { throw "Failed to build" } if($LASTEXITCODE -ne 0) { throw "Failed to build" }
} }

View file

@ -58,8 +58,6 @@ source "$REPOROOT/scripts/common/_prettyprint.sh"
BUILD=1 BUILD=1
LINUX_PORTABLE_INSTALL_ARGS= LINUX_PORTABLE_INSTALL_ARGS=
ALL_LINUX_INSTALLERS_TARGET=
GENERATE_INSTALLERS_TARGET=
CUSTOM_BUILD_ARGS= CUSTOM_BUILD_ARGS=
# Set nuget package cache under the repo # Set nuget package cache under the repo
@ -84,7 +82,7 @@ while [[ $# > 0 ]]; do
--nobuild) --nobuild)
BUILD=0 BUILD=0
;; ;;
--architecture) -a|--architecture)
ARCHITECTURE=$2 ARCHITECTURE=$2
shift shift
;; ;;
@ -100,31 +98,19 @@ while [[ $# > 0 ]]; do
LINUX_PORTABLE_INSTALL_ARGS="--runtime-id linux-x64" LINUX_PORTABLE_INSTALL_ARGS="--runtime-id linux-x64"
CUSTOM_BUILD_ARGS="/p:Rid=\"linux-x64\" /p:OSName=\"linux\" /p:IslinuxPortable=\"true\"" CUSTOM_BUILD_ARGS="/p:Rid=\"linux-x64\" /p:OSName=\"linux\" /p:IslinuxPortable=\"true\""
;; ;;
--all-linux-installers)
ALL_LINUX_INSTALLERS_TARGET="/t:BuildAndPublishAllLinuxDistrosNativeInstallers"
;;
--generate-installers)
GENERATE_INSTALLERS_TARGET="/t:GenerateInstallersAndCopyOutOfSandBox"
;;
--stage0) --stage0)
STAGE0_SOURCE_DIR=$2 STAGE0_SOURCE_DIR=$2
shift shift
;; ;;
--help) --help)
echo "Usage: $0 [--configuration <CONFIGURATION>] [--skip-prereqs] [--nopackage] [--docker <IMAGENAME>] [--help]" echo "Usage: $0 [--configuration <CONFIGURATION>] [--architecture <ARCHITECTURE>] [--skip-prereqs] [--nopackage] [--nobuild ] [--help]"
echo "" echo ""
echo "Options:" echo "Options:"
echo " --configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)" echo " --configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
echo " --architecture <ARCHITECTURE> Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)"
echo " --skip-prereqs Skip checks for pre-reqs in dotnet_install" echo " --skip-prereqs Skip checks for pre-reqs in dotnet_install"
echo " --nopackage Skip packaging targets" echo " --nopackage Skip packaging targets"
echo " --nobuild Skip building, showing the command that would be used to build" echo " --nobuild Skip building, showing the command that would be used to build"
echo " --docker <IMAGENAME> Build in Docker using the Dockerfile located in scripts/docker/IMAGENAME"
echo " --linux-portable Builds the Linux portable .NET Tools instead of a distro-specific version."
echo " --all-linux-installers Builds and publishes all the Linux distros' native installers; outer call"
echo " Note: used primarily for 'AllLinuxDistrosNativeInstallers' VSO build."
echo " --generate-installers Builds and publishes all the Linux distros' native installers; inner call"
echo " Note: used primarily for 'AllLinuxDistrosNativeInstallers' VSO build."
echo " --stage0 Set the stage0 source directory. The default is to download it from Azure."
echo " --help Display this help message" echo " --help Display this help message"
exit 0 exit 0
;; ;;
@ -137,6 +123,15 @@ while [[ $# > 0 ]]; do
shift shift
done done
# The first 'pass' call to "dotnet msbuild build.proj" has a hard-coded "WriteDynamicPropsToStaticPropsFiles" target
# therefore, this call should not have other targets defined. Remove all targets passed in as 'extra parameters'.
argsnotargets=( )
for element in ${args[@]} do
if [[ $element != /t:* ]]; then
argsnotargets+=($element)
fi
done
# Create an install directory for the stage 0 CLI # Create an install directory for the stage 0 CLI
[ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_stage0/$ARCHITECTURE [ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_stage0/$ARCHITECTURE
[ -d "$DOTNET_INSTALL_DIR" ] || mkdir -p $DOTNET_INSTALL_DIR [ -d "$DOTNET_INSTALL_DIR" ] || mkdir -p $DOTNET_INSTALL_DIR
@ -179,12 +174,10 @@ fi
# Disable first run since we want to control all package sources # Disable first run since we want to control all package sources
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
echo "${args[@]}"
if [ $BUILD -eq 1 ]; then if [ $BUILD -eq 1 ]; then
dotnet msbuild build.proj /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $args dotnet msbuild build.proj /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $argsnotargets
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 dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $args
else else
echo "Not building due to --nobuild" echo "Not building due to --nobuild"
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'" echo "Command that would be run is: 'dotnet msbuild build.proj /m /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $args'"
fi fi