From d6f64b37c2cfee76c8b1269d688384ced30ecd21 Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Tue, 7 Sep 2021 23:48:10 +0200 Subject: [PATCH] Source-build BAR publishing fixed (#3040) --- azure-pipelines.yml | 9 +++- eng/SourceBuild.props | 2 + scripts/build.ps1 | 22 ++++++-- scripts/build/TestPlatform.Dependencies.props | 2 +- scripts/vsts-prebuild.sh | 52 +++++++++++++++++++ 5 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 scripts/vsts-prebuild.sh diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 527d60a371..b0afa9aa39 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -140,8 +140,15 @@ jobs: vmImage: $[ variables['vmImage'] ] variables: buildConfiguration: 'Release' + VSTestRTMBuild: 'false' steps: - - script: ./build.sh -c $(buildConfiguration) + - script: chmod +x ./scripts/vsts-prebuild.sh + displayName: 'Preparing for set version' + + - script: ./scripts/vsts-prebuild.sh -build "preview-$(Build.BuildNumber)" -rtm "$(VSTestRTMBuild)" -branch "$(Build.SourceBranch)" + displayName: 'Set Version' + + - script: ./build.sh -c $(buildConfiguration) -v "$(BuildVersionPrefix)" -vs "$(BuildVersionSuffix)" -ci true -verbose displayName: 'Build' - script: ./test.sh -c $(buildConfiguration) -p Unit diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props index 7c23bbf8e4..b365645c34 100644 --- a/eng/SourceBuild.props +++ b/eng/SourceBuild.props @@ -9,6 +9,8 @@ ./build.sh -DotNetBuildFromSource + $(InnerBuildArgs) -v "$(BuildVersionPrefix)" + $(InnerBuildArgs) -vs "$(BuildVersionSuffix)" $(InnerBuildArgs) -DotNetCoreSdkDir $(DotNetRoot) $(InnerBuildArgs) -c $(Configuration) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index faa3cc5d92..d69c552b71 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -95,6 +95,7 @@ $TPB_CIBuild = $CIBuild $TPB_PublishTests = $PublishTestArtifacts $TPB_LocalizedBuild = !$DisableLocalizedBuild $TPB_PackageOutDir = Join-Path $env:TP_OUT_DIR $TPB_Configuration\packages +$TPB_SourceBuildPackageOutDir = Join-Path $TPB_PackageOutDir "source-build" $language = @("cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-BR", "ru", "tr", "zh-Hans", "zh-Hant") @@ -970,15 +971,21 @@ function Update-VsixVersion($vsixProjectDir) Write-Log "Update-VsixVersion: Completed." } -function Generate-Manifest +function Generate-Manifest ($PackageFolder) { - Write-Log "Generate-Manifest: Started." + $packagesFolderName = [System.IO.Path]::GetFileName($PackageFolder) + Write-Log "Generate-Manifest ($packagesFolderName): Started." $generateManifestPath = Join-Path $env:TP_ROOT_DIR "scripts\build\GenerateManifest.proj" $msbuildPath = Locate-MSBuildPath - & $msbuildPath $generateManifestPath /t:PublishToBuildAssetRegistry /p:PackagesToPublishPattern=$TPB_PackageOutDir\*.nupkg /p:BUILD_BUILDNUMBER=$BuildNumber /p:Configuration=$TPB_Configuration /bl:"$env:TP_OUT_DIR\log\$Configuration\manifest-generation.binlog" - Write-Log "Generate-Manifest: Completed." + & $msbuildPath $generateManifestPath /t:PublishToBuildAssetRegistry /p:PackagesToPublishPattern=$PackageFolder\*.nupkg ` + /p:BUILD_BUILDNUMBER=$BuildNumber ` + /p:PackagesPath="$PackageFolder\" ` + /p:Configuration=$TPB_Configuration ` + /bl:"$env:TP_OUT_DIR\log\$Configuration\manifest-generation-$packagesFolderName.binlog" + + Write-Log "Generate-Manifest ($packagesFolderName): Completed." } function Build-SpecificProjects @@ -1078,7 +1085,12 @@ if ($Force -or $Steps -contains "Publish") { } if ($Force -or $Steps -contains "Publish" -or $Steps -contains "Manifest") { - Generate-Manifest + Generate-Manifest -PackageFolder $TPB_PackageOutDir + if (Test-Path $TPB_SourceBuildPackageOutDir) + { + Generate-Manifest -PackageFolder $TPB_SourceBuildPackageOutDir + } + Copy-PackageIntoStaticDirectory } diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index cffa3e3157..2597030e39 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -1,4 +1,4 @@ - + 15.8.3247 diff --git a/scripts/vsts-prebuild.sh b/scripts/vsts-prebuild.sh new file mode 100644 index 0000000000..fd80684ad5 --- /dev/null +++ b/scripts/vsts-prebuild.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Copyright (c) Microsoft. All rights reserved. + +set -o nounset # Fail on uninitialized variables. +set -e # Fail on non-zero exit code. + +# Parameter +TP_BUILD_SUFFIX="dev" +BRANCH= +IS_RTM=false + +while [ $# -gt 0 ]; do + lowerI="$(echo ${1:-} | awk '{print tolower($0)}')" + case $lowerI in + -build) + TP_BUILD_SUFFIX=$2 + shift + ;; + -branch) + BRANCH=$2 + shift + ;; + -rtm) + IS_RTM=$2 + shift + ;; + *) + break + ;; + esac + shift +done + +TP_ROOT_DIR=$(cd "$(dirname "$0")/.."; pwd -P) +TP_BUILD_PREFIX=$(grep TPVersionPrefix $TP_ROOT_DIR/scripts/build/TestPlatform.Settings.targets | head -1 | cut -d'>' -f2 | cut -d'<' -f1 || echo $TP_BUILD_PREFIX) +PACKAGE_VERSION="$TP_BUILD_PREFIX-$TP_BUILD_SUFFIX" + +# Script +if [ $IS_RTM == true ]; then + PACKAGE_VERSION="$TP_BUILD_PREFIX" + TP_BUILD_SUFFIX= +else + if [ ! -z "$BRANCH" ] && [[ $BRANCH =~ ^refs\/heads\/rel\/.*$ ]]; then + TP_BUILD_SUFFIX="${TP_BUILD_SUFFIX/preview/release}" + fi + + PACKAGE_VERSION="$TP_BUILD_PREFIX-$TP_BUILD_SUFFIX" +fi + +echo "##vso[task.setvariable variable=BuildVersionPrefix;]$TP_BUILD_PREFIX" +echo "##vso[task.setvariable variable=BuildVersionSuffix;]$TP_BUILD_SUFFIX" +echo "##vso[task.setvariable variable=PackageVersion;]$PACKAGE_VERSION" \ No newline at end of file