Allow project builds from script (#201)
authorViktor Hofer <viktor.hofer@microsoft.com>
Mon, 25 Nov 2019 14:15:21 +0000 (15:15 +0100)
committerGitHub <noreply@github.com>
Mon, 25 Nov 2019 14:15:21 +0000 (15:15 +0100)
* Allow project builds from script

* Fix installer builds

eng/build.ps1
eng/build.sh
eng/pipelines/installer/jobs/bash-build.yml
eng/pipelines/installer/jobs/osx-build.yml
eng/pipelines/installer/jobs/windows-build.yml

index c680efe..9e889c9 100644 (file)
@@ -94,10 +94,25 @@ if ($null -ne $properties -and $actionPassedIn -ne $true) {
   $actionPassedIn = @(Compare-Object -ReferenceObject $properties -DifferenceObject $actions.ForEach({ "-" + $_ }) -ExcludeDifferent -IncludeEqual).Length -ne 0
 }
 
-if (!$actionPassedIn -or $subsetCategory -ne "libraries") {
+if (!$actionPassedIn) {
   $arguments = "-restore -build"
 }
 
+$possibleDirToBuild = if($properties.Length -gt 0) { $properties[0]; } else { $null }
+
+if ($null -ne $possibleDirToBuild -and $subsetCategory -eq "libraries") {
+  $dtb = $possibleDirToBuild.TrimEnd('\')
+  if (Test-Path $dtb) {
+    $properties[0] = "/p:DirectoryToBuild=$(Resolve-Path $dtb)"
+  }
+  else {
+    $dtb = Join-Path "$PSSCriptRoot\..\src\libraries" $dtb
+    if (Test-Path $dtb) {
+      $properties[0] = "/p:DirectoryToBuild=$(Resolve-Path $dtb)"
+    }
+  }
+}
+
 foreach ($argument in $PSBoundParameters.Keys)
 {
   switch($argument)
index fb9f0cf..8b35fd5 100755 (executable)
@@ -52,9 +52,10 @@ extraargs=''
 build=false
 buildtests=false
 subsetCategory=''
+checkedPossibleDirectoryToBuild=false
 
 # Check if an action is passed in
-declare -a actions=("r" "restore" "b" "build" "rebuild" "t" "test" "buildtests")
+declare -a actions=("r" "restore" "b" "build" "buildtests" "rebuild" "t" "test" "pack" "sign" "publish" "clean")
 actInt=($(comm -12 <(printf '%s\n' "${actions[@]/#/-}" | sort) <(printf '%s\n' "${@/#--/-}" | sort)))
 
 while [[ $# > 0 ]]; do
@@ -118,6 +119,17 @@ while [[ $# > 0 ]]; do
       ;;
       *)
       ea=$1
+      
+      if [[ $checkedPossibleDirectoryToBuild == false ]] && [[ $subsetCategory == "libraries" ]]; then
+        checkedPossibleDirectoryToBuild=true
+
+        if [[ -d "$1" ]]; then
+          ea="/p:DirectoryToBuild=$1"
+        elif [[ -d "$scriptroot/../src/libraries/$1" ]]; then
+          ea="/p:DirectoryToBuild=$scriptroot/../src/libraries/$1"
+        fi
+      fi
+
       extraargs="$extraargs $ea"
       shift 1
       ;;
@@ -132,7 +144,7 @@ if [[ "$buildtests" == true ]]; then
   fi
 fi
 
-if [ ${#actInt[@]} -eq 0 ] || [ "$subsetCategory" != "libraries" ]; then
+if [ ${#actInt[@]} -eq 0 ]; then
     arguments="-restore -build $arguments"
 fi
 
index 39adc5f..42661f0 100644 (file)
@@ -66,7 +66,7 @@ jobs:
       # parameter is empty, AzDO replaces it with empty space without chomping the extra newline.
       # This causes a newline in the arg string that causes failure.
       BuildArguments: >-
-        --ci --test
+        --restore --build --ci --test
         /p:CrossBuild=${{ parameters.crossBuild }}
         /p:DisableCrossgen=${{ parameters.disableCrossgen }}
         /p:PortableBuild=${{ parameters.portableBuild }}
index 74554f1..a3f79a8 100644 (file)
@@ -26,7 +26,7 @@ jobs:
     - task: NuGetAuthenticate@0
 
   - script: >-
-      $(Build.SourcesDirectory)/$(buildScriptFileName).sh --ci --test
+      $(Build.SourcesDirectory)/$(buildScriptFileName).sh --restore --build --ci --test
       /p:OfficialBuildId=$(OfficialBuildId)
       /p:StripSymbols=true
       $(CommonMSBuildArgs)
index 57ff8c7..aa90d94 100644 (file)
@@ -58,7 +58,7 @@ jobs:
       displayName: Clear NuGet http cache (if exists)
 
     - script: >-
-        $(buildScriptFileName).cmd -ci -test
+        $(buildScriptFileName).cmd -restore -build -ci -test
         $(CommonMSBuildArgs)
         $(MsbuildSigningArguments)
       displayName: Build