From 537a7816cd9a00943f4998ca1fb7f52f580ba7e7 Mon Sep 17 00:00:00 2001 From: Jon Fortescue Date: Tue, 16 Mar 2021 17:27:42 -0700 Subject: [PATCH 1/8] Add OneLocBuild template to arcade (#6977) --- eng/common/generate-locproject.ps1 | 101 +++++++++++++++++++++++ eng/common/templates/job/onelocbuild.yml | 75 +++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 eng/common/generate-locproject.ps1 create mode 100644 eng/common/templates/job/onelocbuild.yml diff --git a/eng/common/generate-locproject.ps1 b/eng/common/generate-locproject.ps1 new file mode 100644 index 00000000000..9e2f7ad98bf --- /dev/null +++ b/eng/common/generate-locproject.ps1 @@ -0,0 +1,101 @@ +Param( + [Parameter(Mandatory=$true)][string] $SourcesDirectory, # Directory where source files live; if using a Localize directory it should live in here + [string] $LanguageSet = 'VS_Main_Languages', # Language set to be used in the LocProject.json + [switch] $UseCheckedInLocProjectJson, # When set, generates a LocProject.json and compares it to one that already exists in the repo; otherwise just generates one + [switch] $CreateNeutralXlfs # Creates neutral xlf files. Only set to false when running locally +) + +# Generates LocProject.json files for the OneLocBuild task. OneLocBuildTask is described here: +# https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task + +Set-StrictMode -Version 2.0 +$ErrorActionPreference = "Stop" +. $PSScriptRoot\tools.ps1 + +Import-Module -Name (Join-Path $PSScriptRoot 'native\CommonLibrary.psm1') + +$exclusionsFilePath = "$SourcesDirectory\Localize\LocExclusions.json" +$exclusions = @{ Exclusions = @() } +if (Test-Path -Path $exclusionsFilePath) +{ + $exclusions = Get-Content "$exclusionsFilePath" | ConvertFrom-Json +} + +Push-Location "$SourcesDirectory" # push location for Resolve-Path -Relative to work + +# Template files +$jsonFiles = @() +$jsonFiles += Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "\.template\.config\\localize\\en\..+\.json" } # .NET templating pattern +$jsonFiles += Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "en\\strings\.json" } # current winforms pattern + +$xlfFiles = @() + +$allXlfFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory\*\*.xlf" +$langXlfFiles = @() +if ($allXlfFiles) { + $null = $allXlfFiles[0].FullName -Match "\.([\w-]+)\.xlf" # matches '[langcode].xlf' + $firstLangCode = $Matches.1 + $langXlfFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory\*\*.$firstLangCode.xlf" +} +$langXlfFiles | ForEach-Object { + $null = $_.Name -Match "([^.]+)\.[\w-]+\.xlf" # matches '[filename].[langcode].xlf' + + $destinationFile = "$($_.Directory.FullName)\$($Matches.1).xlf" + $xlfFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru +} + +$locFiles = $jsonFiles + $xlfFiles + +$locJson = @{ + Projects = @( + @{ + LanguageSet = $LanguageSet + LocItems = @( + $locFiles | ForEach-Object { + $outputPath = "Localize\$(($_.DirectoryName | Resolve-Path -Relative) + "\")" + $continue = $true + foreach ($exclusion in $exclusions.Exclusions) { + if ($outputPath.Contains($exclusion)) + { + $continue = $false + } + } + $sourceFile = ($_.FullName | Resolve-Path -Relative) + if (!$CreateNeutralXlfs -and $_.Extension -eq '.xlf') { + Remove-Item -Path $sourceFile + } + if ($continue) + { + return @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnName" + OutputPath = $outputPath + } + } + } + ) + } + ) +} + +$json = ConvertTo-Json $locJson -Depth 5 +Write-Host "(NETCORE_ENGINEERING_TELEMETRY=Build) LocProject.json generated:`n`n$json`n`n" +Pop-Location + +if (!$UseCheckedInLocProjectJson) { + New-Item "$SourcesDirectory\Localize\LocProject.json" -Force # Need this to make sure the Localize directory is created + Set-Content "$SourcesDirectory\Localize\LocProject.json" $json +} +else { + New-Item "$SourcesDirectory\Localize\LocProject-generated.json" -Force # Need this to make sure the Localize directory is created + Set-Content "$SourcesDirectory\Localize\LocProject-generated.json" $json + + if ((Get-FileHash "$SourcesDirectory\Localize\LocProject-generated.json").Hash -ne (Get-FileHash "$SourcesDirectory\Localize\LocProject.json").Hash) { + Write-PipelineTaskError -Type "warning" -Message "Existing LocProject.json differs from generated LocProject.json. Download LocProject-generated.json and compare them." + + exit 1 + } + else { + Write-Host "Generated LocProject.json and current LocProject.json are identical." + } +} \ No newline at end of file diff --git a/eng/common/templates/job/onelocbuild.yml b/eng/common/templates/job/onelocbuild.yml new file mode 100644 index 00000000000..6abc041cd1c --- /dev/null +++ b/eng/common/templates/job/onelocbuild.yml @@ -0,0 +1,75 @@ +parameters: + # Optional: dependencies of the job + dependsOn: '' + + # Optional: A defined YAML pool - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#pool + pool: + vmImage: vs2017-win2016 + + CeapexPat: $(dn-bot-ceapex-package-r) # PAT for the loc AzDO instance https://dev.azure.com/ceapex + GithubPat: $(BotAccount-dotnet-bot-repo-PAT) + + SourcesDirectory: $(Build.SourcesDirectory) + CreatePr: true + UseCheckedInLocProjectJson: false + LanguageSet: VS_Main_Languages + LclSource: lclFilesInRepo + LclPackageId: '' + RepoType: gitHub + +jobs: +- job: OneLocBuild + + dependsOn: ${{ parameters.dependsOn }} + + displayName: OneLocBuild + + pool: ${{ parameters.pool }} + + variables: + - group: OneLocBuildVariables # Contains the CeapexPat and GithubPat + - name: _GenerateLocProjectArguments + value: -SourcesDirectory ${{ parameters.SourcesDirectory }} + -LanguageSet "${{ parameters.LanguageSet }}" + -CreateNeutralXlfs + - ${{ if eq(parameters.UseCheckedInLocProjectJson, 'true') }}: + - name: _GenerateLocProjectArguments + value: ${{ variables._GenerateLocProjectArguments }} -UseCheckedInLocProjectJson + + + steps: + - task: Powershell@2 + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/generate-locproject.ps1 + arguments: $(_GenerateLocProjectArguments) + displayName: Generate LocProject.json + + - task: OneLocBuild@2 + displayName: OneLocBuild + inputs: + locProj: Localize/LocProject.json + outDir: $(Build.ArtifactStagingDirectory) + lclSource: ${{ parameters.LclSource }} + lclPackageId: ${{ parameters.LclPackageId }} + isCreatePrSelected: ${{ parameters.CreatePr }} + repoType: ${{ parameters.RepoType }} + gitHubPatVariable: "${{ parameters.GithubPat }}" + packageSourceAuth: patAuth + patVariable: ${{ parameters.CeapexPat }} + condition: always() + + - task: PublishBuildArtifacts@1 + displayName: Publish Localization Files + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)/loc' + PublishLocation: Container + ArtifactName: Loc + condition: always() + + - task: PublishBuildArtifacts@1 + displayName: Publish LocProject.json + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/Localize/' + PublishLocation: Container + ArtifactName: Loc + condition: always() \ No newline at end of file From be0bb0c29106eb9f09b8b902a763a9b6275a1194 Mon Sep 17 00:00:00 2001 From: Jon Fortescue Date: Thu, 18 Mar 2021 09:22:22 -0700 Subject: [PATCH 2/8] Add telemetry to generate-locproject.ps1 (#7122) --- eng/common/generate-locproject.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/generate-locproject.ps1 b/eng/common/generate-locproject.ps1 index 9e2f7ad98bf..ad3e80651fe 100644 --- a/eng/common/generate-locproject.ps1 +++ b/eng/common/generate-locproject.ps1 @@ -79,7 +79,7 @@ $locJson = @{ } $json = ConvertTo-Json $locJson -Depth 5 -Write-Host "(NETCORE_ENGINEERING_TELEMETRY=Build) LocProject.json generated:`n`n$json`n`n" +Write-Host "LocProject.json generated:`n`n$json`n`n" Pop-Location if (!$UseCheckedInLocProjectJson) { @@ -91,7 +91,7 @@ else { Set-Content "$SourcesDirectory\Localize\LocProject-generated.json" $json if ((Get-FileHash "$SourcesDirectory\Localize\LocProject-generated.json").Hash -ne (Get-FileHash "$SourcesDirectory\Localize\LocProject.json").Hash) { - Write-PipelineTaskError -Type "warning" -Message "Existing LocProject.json differs from generated LocProject.json. Download LocProject-generated.json and compare them." + Write-PipelineTelemetryError -Category "OneLocBuild" -Message "Existing LocProject.json differs from generated LocProject.json. Download LocProject-generated.json and compare them." exit 1 } From ebf342fbcfc872d00dc82f15592bd23c3255e9ad Mon Sep 17 00:00:00 2001 From: Jon Fortescue Date: Mon, 22 Mar 2021 17:55:04 -0700 Subject: [PATCH 3/8] Update OneLocBuild stuff for AzDO repos (#7136) --- eng/common/generate-locproject.ps1 | 2 +- eng/common/templates/job/onelocbuild.yml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/eng/common/generate-locproject.ps1 b/eng/common/generate-locproject.ps1 index ad3e80651fe..f5cf87e721d 100644 --- a/eng/common/generate-locproject.ps1 +++ b/eng/common/generate-locproject.ps1 @@ -52,7 +52,7 @@ $locJson = @{ LanguageSet = $LanguageSet LocItems = @( $locFiles | ForEach-Object { - $outputPath = "Localize\$(($_.DirectoryName | Resolve-Path -Relative) + "\")" + $outputPath = "$(($_.DirectoryName | Resolve-Path -Relative) + "\")" $continue = $true foreach ($exclusion in $exclusions.Exclusions) { if ($outputPath.Contains($exclusion)) diff --git a/eng/common/templates/job/onelocbuild.yml b/eng/common/templates/job/onelocbuild.yml index 6abc041cd1c..928a70cda2c 100644 --- a/eng/common/templates/job/onelocbuild.yml +++ b/eng/common/templates/job/onelocbuild.yml @@ -46,16 +46,19 @@ jobs: - task: OneLocBuild@2 displayName: OneLocBuild + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) inputs: locProj: Localize/LocProject.json outDir: $(Build.ArtifactStagingDirectory) lclSource: ${{ parameters.LclSource }} lclPackageId: ${{ parameters.LclPackageId }} isCreatePrSelected: ${{ parameters.CreatePr }} - repoType: ${{ parameters.RepoType }} - gitHubPatVariable: "${{ parameters.GithubPat }}" packageSourceAuth: patAuth patVariable: ${{ parameters.CeapexPat }} + ${{ if eq(parameters.RepoType, 'gitHub') }}: + repoType: ${{ parameters.RepoType }} + gitHubPatVariable: "${{ parameters.GithubPat }}" condition: always() - task: PublishBuildArtifacts@1 From 7082cf51e1a5d84027bb7c2d660620e4ce3b8e42 Mon Sep 17 00:00:00 2001 From: Jon Fortescue Date: Tue, 23 Mar 2021 15:18:43 -0700 Subject: [PATCH 4/8] Fix LocProject.json generation file finding bug (#7143) --- eng/common/generate-locproject.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/generate-locproject.ps1 b/eng/common/generate-locproject.ps1 index f5cf87e721d..daee11b2d70 100644 --- a/eng/common/generate-locproject.ps1 +++ b/eng/common/generate-locproject.ps1 @@ -38,7 +38,7 @@ if ($allXlfFiles) { $langXlfFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory\*\*.$firstLangCode.xlf" } $langXlfFiles | ForEach-Object { - $null = $_.Name -Match "([^.]+)\.[\w-]+\.xlf" # matches '[filename].[langcode].xlf' + $null = $_.Name -Match "(.+)\.[\w-]+\.xlf" # matches '[filename].[langcode].xlf' $destinationFile = "$($_.Directory.FullName)\$($Matches.1).xlf" $xlfFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru From bd0e671ef9b13dc4febcb3cb3ae17d1941626ccc Mon Sep 17 00:00:00 2001 From: Jon Fortescue Date: Mon, 29 Mar 2021 15:26:24 -0700 Subject: [PATCH 5/8] Add documentation for OneLocBuild template (#7154) --- Documentation/OneLocBuild.md | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/OneLocBuild.md diff --git a/Documentation/OneLocBuild.md b/Documentation/OneLocBuild.md new file mode 100644 index 00000000000..28f854e0a31 --- /dev/null +++ b/Documentation/OneLocBuild.md @@ -0,0 +1,80 @@ +# Localization with OneLocBuild in Arcade + +As of April 1, 2021, all .NET repositories will be using OneLocBuild for localization. Documentation on this system can +be found [here](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task). +This system is **not a replacement for Xliff-Tasks**; rather, it is replacing the localization team's old system called +Simple Loc. Xliff-Tasks will continue to be used in addition to OneLocBuild. + +To make OneLocBuild easier to use, we have integrated the task into Arcade. This integration is a job template +([here](/eng/common/templates/job/onelocbuild.yml)) that is described in this document. + +## LocProject.json Index File + +The core component of OneLocBuild is the LocProject.json file. This file is an index file containing references to +all of the files to localize in your repository. In order to reduce overhead for repo owners, we are auto-generating +the LocProject.json file (PowerShell script [here](/eng/common/generate-locproject.ps1)). This script and the +OneLocBuild Azure DevOps task are both wrapped in the onelocbuild.yml job template. + +The script searches your checked-in code for all localized XLF files and template JSON files. Files can be excluded +using a checked in file (/Localize/LocExclusions.json). The LocExclusions file excludes files based on simple matching. +For example, the LocExclusions.json file below will exclude everything in a directory called `tests` and any file +which include `test.xlf` in its name. + +```json +{ + "Exclusions": [ + "\\tests\\", + "test.xlf" + ] +} +``` + +The selected files are then added to a generated LocProject.json file. At this point, template currently provides two options +for how to proceed. + +### Build-Time Generation + +**The recommended path** is to have the script pass the generated LocProject.json directly to the OneLocBuild task. +This is the simpler of the two methods and removes the overhead of needing to maintain a checked in +LocProject.json file. The LocProject.json file is emitted in build logs and as a build artifact for examination. + +### Build-Time Validation + +While it is **not the recommended path**, repos can instead opt to check in a static LocProject.json and have the +script compare it against the generated one. If they differ, the script will break the build so that a dev can +update either the LocProject.json or the LocExclusions.json file accordingly. + +Because the script can be run locally, devs can also do this validation prior to pushing their changes. + +### Custom LocProject.json Files + +Currently, the LocProject.json generation script only creates fairly uniform LocProject.json files. If your repository +requires the use of any of the more complex LocProject.json features as described in the OneLocBuild docs linked above, +the OneLocBuild template in this doc will not work and you will need to check in and maintain the LocProject.json file +manually. + +## OneLocBuild Template Parameters + +The most basic structure for calling the OneLocBuild template is: + +```yaml +jobs: +- template: /eng/common/templates/job/onelocbuild.yml + parameters: + LclSource: lclFilesfromPackage + LclPackageId: 'LCL-PACKAGE-ID' +``` + +The parameters that can be passed to the template are as follows: + +| **Parameter** | **Default Value** | **Notes** | +|:-:|:-:|-| +| `RepoType` | `'gitHub'` | Should be set to `'gitHub'` for GitHub-based repositories and `'azureDevOps'` for Azure DevOps-based ones. | +| `SourcesDirectory` | `$(Build.SourcesDirectory)` | This is the root directory for your repository source code. | +| `CreatePr` | `true` | When set to `true`, instructs the OneLocBuild task to make a PR back to the source repository containing the localized files. | +| `UseCheckedInLocProjectJson` | `false` | When set to `true`, instructs the LocProject.json generation script to use build-time validation rather than build-time generation, as described above. | +| `LanguageSet` | `VS_Main_Languages` | This defines the `LanguageSet` of the LocProject.json as described in the [OneLocBuild task documentation](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task?anchor=languageset%2C-languages-(required)). | +| `LclSource` | `LclFilesInRepo` | This passes the `LclSource` input to the OneLocBuild task as described in [its documentation](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task?anchor=languageset%2C-languages-(required)). For most repos, this should be set to `LclFilesfromPackage`. | +| `LclPackageId` | `''` | When `LclSource` is set to `LclFilesfromPackage`, this passes in the package ID as described in the [OneLocBuild task documentation](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task?anchor=scenario-2%3A-lcl-files-from-a-package). | + +It is recommended that you set `LclSource` and `LclPackageId` as shown in the example above. \ No newline at end of file From 0c3520e85c1d3d647bfcb8a2453b88c1200848a4 Mon Sep 17 00:00:00 2001 From: Jon Fortescue Date: Wed, 14 Apr 2021 08:59:59 -0700 Subject: [PATCH 6/8] Add autocomplete PR flag for OneLocBuild template (#7228) --- Documentation/OneLocBuild.md | 1 + eng/common/templates/job/onelocbuild.yml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Documentation/OneLocBuild.md b/Documentation/OneLocBuild.md index 28f854e0a31..784c5159890 100644 --- a/Documentation/OneLocBuild.md +++ b/Documentation/OneLocBuild.md @@ -72,6 +72,7 @@ The parameters that can be passed to the template are as follows: | `RepoType` | `'gitHub'` | Should be set to `'gitHub'` for GitHub-based repositories and `'azureDevOps'` for Azure DevOps-based ones. | | `SourcesDirectory` | `$(Build.SourcesDirectory)` | This is the root directory for your repository source code. | | `CreatePr` | `true` | When set to `true`, instructs the OneLocBuild task to make a PR back to the source repository containing the localized files. | +| `AutoCompletePr` | `false` | When set to `true`, instructs the OneLocBuild task to autocomplete the created PR. Requires permissions to bypass any checks on the main branch. | | `UseCheckedInLocProjectJson` | `false` | When set to `true`, instructs the LocProject.json generation script to use build-time validation rather than build-time generation, as described above. | | `LanguageSet` | `VS_Main_Languages` | This defines the `LanguageSet` of the LocProject.json as described in the [OneLocBuild task documentation](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task?anchor=languageset%2C-languages-(required)). | | `LclSource` | `LclFilesInRepo` | This passes the `LclSource` input to the OneLocBuild task as described in [its documentation](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task?anchor=languageset%2C-languages-(required)). For most repos, this should be set to `LclFilesfromPackage`. | diff --git a/eng/common/templates/job/onelocbuild.yml b/eng/common/templates/job/onelocbuild.yml index 928a70cda2c..d2b271ec1ac 100644 --- a/eng/common/templates/job/onelocbuild.yml +++ b/eng/common/templates/job/onelocbuild.yml @@ -11,6 +11,7 @@ parameters: SourcesDirectory: $(Build.SourcesDirectory) CreatePr: true + AutoCompletePr: false UseCheckedInLocProjectJson: false LanguageSet: VS_Main_Languages LclSource: lclFilesInRepo @@ -54,6 +55,8 @@ jobs: lclSource: ${{ parameters.LclSource }} lclPackageId: ${{ parameters.LclPackageId }} isCreatePrSelected: ${{ parameters.CreatePr }} + ${{ if eq(parameters.CreatePr, true) }}: + isAutoCompletePrSelected: ${{ parameters.AutoCompletePr }} packageSourceAuth: patAuth patVariable: ${{ parameters.CeapexPat }} ${{ if eq(parameters.RepoType, 'gitHub') }}: From 5a7d7b20b65c44c95111b3905a66cfb473b61f42 Mon Sep 17 00:00:00 2001 From: Jon Fortescue Date: Mon, 19 Apr 2021 14:53:28 -0700 Subject: [PATCH 7/8] Add support for LangIDOnPath templates (#7187) --- eng/common/generate-locproject.ps1 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/eng/common/generate-locproject.ps1 b/eng/common/generate-locproject.ps1 index daee11b2d70..2907f916d6f 100644 --- a/eng/common/generate-locproject.ps1 +++ b/eng/common/generate-locproject.ps1 @@ -66,10 +66,19 @@ $locJson = @{ } if ($continue) { - return @{ - SourceFile = $sourceFile - CopyOption = "LangIDOnName" - OutputPath = $outputPath + if ($_.Directory.Name -eq 'en' -and $_.Extension -eq '.json') { + return @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnPath" + OutputPath = "$($_.Directory.Parent.FullName | Resolve-Path -Relative)\" + } + } + else { + return @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnName" + OutputPath = $outputPath + } } } } From 27038f288c331195b40cd336e4f0cd7819265f83 Mon Sep 17 00:00:00 2001 From: Jon Fortescue Date: Thu, 22 Apr 2021 13:14:35 -0700 Subject: [PATCH 8/8] Add condition parameter to OneLocBuild (#7263) --- Documentation/OneLocBuild.md | 1 + eng/common/templates/job/onelocbuild.yml | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/OneLocBuild.md b/Documentation/OneLocBuild.md index 784c5159890..646f4f9cc45 100644 --- a/Documentation/OneLocBuild.md +++ b/Documentation/OneLocBuild.md @@ -77,5 +77,6 @@ The parameters that can be passed to the template are as follows: | `LanguageSet` | `VS_Main_Languages` | This defines the `LanguageSet` of the LocProject.json as described in the [OneLocBuild task documentation](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task?anchor=languageset%2C-languages-(required)). | | `LclSource` | `LclFilesInRepo` | This passes the `LclSource` input to the OneLocBuild task as described in [its documentation](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task?anchor=languageset%2C-languages-(required)). For most repos, this should be set to `LclFilesfromPackage`. | | `LclPackageId` | `''` | When `LclSource` is set to `LclFilesfromPackage`, this passes in the package ID as described in the [OneLocBuild task documentation](https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task?anchor=scenario-2%3A-lcl-files-from-a-package). | +| `condition` | `''` | Allows for conditionalizing the template's steps on build-time variables. | It is recommended that you set `LclSource` and `LclPackageId` as shown in the example above. \ No newline at end of file diff --git a/eng/common/templates/job/onelocbuild.yml b/eng/common/templates/job/onelocbuild.yml index d2b271ec1ac..b27d6faf303 100644 --- a/eng/common/templates/job/onelocbuild.yml +++ b/eng/common/templates/job/onelocbuild.yml @@ -17,6 +17,7 @@ parameters: LclSource: lclFilesInRepo LclPackageId: '' RepoType: gitHub + condition: '' jobs: - job: OneLocBuild @@ -44,6 +45,7 @@ jobs: filePath: $(Build.SourcesDirectory)/eng/common/generate-locproject.ps1 arguments: $(_GenerateLocProjectArguments) displayName: Generate LocProject.json + condition: ${{ parameters.condition }} - task: OneLocBuild@2 displayName: OneLocBuild @@ -62,7 +64,7 @@ jobs: ${{ if eq(parameters.RepoType, 'gitHub') }}: repoType: ${{ parameters.RepoType }} gitHubPatVariable: "${{ parameters.GithubPat }}" - condition: always() + condition: ${{ parameters.condition }} - task: PublishBuildArtifacts@1 displayName: Publish Localization Files @@ -70,7 +72,7 @@ jobs: PathtoPublish: '$(Build.ArtifactStagingDirectory)/loc' PublishLocation: Container ArtifactName: Loc - condition: always() + condition: ${{ parameters.condition }} - task: PublishBuildArtifacts@1 displayName: Publish LocProject.json @@ -78,4 +80,4 @@ jobs: PathtoPublish: '$(Build.SourcesDirectory)/Localize/' PublishLocation: Container ArtifactName: Loc - condition: always() \ No newline at end of file + condition: ${{ parameters.condition }} \ No newline at end of file