diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 90c4222beda..40c339d7ffa 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,6 +78,8 @@ variables: value: $(Build.Arcade.ArtifactsPath)TestResults/$(_BuildConfig)/ - name: Build.Arcade.VSIXOutputPath value: $(Build.Arcade.ArtifactsPath)VSIX + - name: _WindowsBuildScript + value: $(Build.SourcesDirectory)/build.cmd -ci -NativeToolsOnMachine # Enable extraction of published outputs for analysis - name: GDN_EXTRACT_TOOLS @@ -125,14 +127,19 @@ variables: value: true # Enable source index only for main branch builds - - ${{ if and(ne(variables['runAsPublic'], 'true'), notin(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}: - - name: enableSourceIndex - value: true - - ${{ else }}: - - name: enableSourceIndex - value: false - - name: sourceIndexBuildCommand - value: $(Build.SourcesDirectory)/build.cmd -ci -NativeToolsOnMachine + - name: sourceIndexCondition + value: | + and( + succeeded(), + or( + eq(variables['forceEnableSourceIndex'], 'true'), + and( + ne(variables['runAsPublic'], 'true'), + notin(variables['Build.Reason'], 'PullRequest'), + eq(variables['Build.SourceBranch'], 'refs/heads/main') + ) + ) + ) resources: repositories: @@ -175,9 +182,16 @@ extends: manifests: true enableMicrobuild: true enableTelemetry: true - enableSourceIndex: ${{ variables['enableSourceIndex'] }} + enableSourceIndex: true sourceIndexParams: - sourceIndexBuildCommand: ${{ variables['sourceIndexBuildCommand'] }} + condition: ${{ variables['sourceIndexCondition'] }} + sourceIndexBuildCommand: '' + preSteps: + - template: /eng/pipelines/templates/RestoreAndBuild.yml + parameters: + buildScript: $(_WindowsBuildScript) + buildConfig: Debug + repoLogPath: $(Build.SourcesDirectory)/artifacts/log/Debug runAsPublic: ${{ variables['runAsPublic'] }} # Publish test logs enablePublishTestResults: true @@ -201,7 +215,7 @@ extends: os: windows variables: - - _buildScript: $(Build.SourcesDirectory)/build.cmd -ci -NativeToolsOnMachine + - _buildScript: $(_WindowsBuildScript) templateContext: outputs: diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index ce540adfa24..eef6c522510 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -23,35 +23,12 @@ parameters: default: false steps: - - task: NodeTool@0 - displayName: Add NodeJS/npm - inputs: - versionSpec: "20.x" - checkLatest: true - - - script: ${{ parameters.buildScript }} - -restore - -warnAsError ${{ parameters.warnAsError }} - /bl:${{ parameters.repoLogPath }}/restore.binlog - displayName: Restore - - - pwsh: | - $(Build.SourcesDirectory)/scripts/Slngen.ps1 -All -NoLaunch - displayName: Create solution - - - script: ${{ parameters.buildScript }} - -restore - -warnAsError ${{ parameters.warnAsError }} - /bl:${{ parameters.repoLogPath }}/restore2.binlog - displayName: Restore solution - - - script: ${{ parameters.buildScript }} - -build - -configuration ${{ parameters.buildConfig }} - -warnAsError ${{ parameters.warnAsError }} - /bl:${{ parameters.repoLogPath }}/build.binlog - $(_OfficialBuildIdArgs) - displayName: Build + - template: /eng/pipelines/templates/RestoreAndBuild.yml + parameters: + buildScript: ${{ parameters.buildScript }} + buildConfig: ${{ parameters.buildConfig }} + repoLogPath: ${{ parameters.repoLogPath }} + warnAsError: ${{ parameters.warnAsError }} - ${{ if ne(parameters.skipTests, 'true') }}: - script: $(Build.SourcesDirectory)/.dotnet/dotnet dotnet-coverage collect diff --git a/eng/pipelines/templates/RestoreAndBuild.yml b/eng/pipelines/templates/RestoreAndBuild.yml new file mode 100644 index 00000000000..9b6bdf5cfa9 --- /dev/null +++ b/eng/pipelines/templates/RestoreAndBuild.yml @@ -0,0 +1,41 @@ +parameters: + - name: buildScript + type: string + - name: buildConfig + type: string + - name: repoLogPath + type: string + - name: warnAsError + type: number + default: 1 + +steps: + - task: NodeTool@0 + displayName: Add NodeJS/npm + inputs: + versionSpec: "20.x" + checkLatest: true + + - script: ${{ parameters.buildScript }} + -restore + -warnAsError ${{ parameters.warnAsError }} + /bl:${{ parameters.repoLogPath }}/restore.binlog + displayName: Restore + + - pwsh: | + $(Build.SourcesDirectory)/scripts/Slngen.ps1 -All -NoLaunch + displayName: Create solution + + - script: ${{ parameters.buildScript }} + -restore + -warnAsError ${{ parameters.warnAsError }} + /bl:${{ parameters.repoLogPath }}/restore2.binlog + displayName: Restore solution + + - script: ${{ parameters.buildScript }} + -build + -configuration ${{ parameters.buildConfig }} + -warnAsError ${{ parameters.warnAsError }} + /bl:${{ parameters.repoLogPath }}/build.binlog + $(_OfficialBuildIdArgs) + displayName: Build