Build the WindowsAppSDK NugetPackage in the Internal transport package pipeline (#1860)

This commit is contained in:
Kyaw Thant 2021-12-01 15:38:38 -08:00 коммит произвёл GitHub
Родитель e48417c378
Коммит 67709b93b0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 225 добавлений и 37 удалений

Просмотреть файл

@ -8,7 +8,6 @@ parameters:
primaryBuildArch: x86
buildFlavor: Release
prereleaseVersionTag: 'prerelease'
publishToMaestro: false
condition: ''
buildPool: ''
@ -105,12 +104,14 @@ jobs:
# displayName: 'build-nupkg.ps1'
- task: PowerShell@2
name: SetVersion
displayName: Update metapackage version
inputs:
targetType: 'inline'
script: |
$packageVersion = '$(version).${{ parameters.prereleaseVersionTag }}'
Write-Host "##vso[task.setvariable variable=packageVersion;]$packageVersion"
Write-Host "##vso[task.setvariable variable=packageVersion;isOutput=true;]$packageVersion"
Write-Host $packageVersion
[xml]$publicNuspec = Get-Content -Path $(Build.SourcesDirectory)\build\NuSpecs\Microsoft.WindowsAppSDK.Foundation.nuspec
$publicNuspec.package.metadata.version = $packageVersion
@ -161,24 +162,6 @@ jobs:
PathtoPublish: '${{ parameters.fullnupkgdir }}'
artifactName: 'FullNuget'
- ${{if parameters.signConfigPattern }}:
# this mysterious guid fixes the "NuGetCommand@2 is ambiguous" error :-(
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet push to ProjectReunion.nuget.internal'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/fullnuget/*.nupkg;!$(Build.ArtifactStagingDirectory)/fullnuget/*.symbols.nupkg'
verbosityPush: 'Detailed'
nuGetFeedType: 'internal'
#Note: The project qualifier is always required when using a feed name. Also, do not use organization scoped feeds.
publishVstsFeed: 'ProjectReunion/Project.Reunion.nuget.internal'
- ${{ if eq(parameters.publishToMaestro, 'true') }}:
- template: ..\..\eng\common\AzurePipelinesTemplates\Maestro-PublishBuildToMaestro-Steps.yml
parameters:
AssetName: 'Microsoft.WindowsAppSDK.Foundation.TransportPackage'
AssetVersion: $(packageVersion)
TriggerSubscription: true
#UNDONE - EHO we need to seed these guid's properly!
#see, e.g. AzurePipelinesTemplates\WindowsAppSDK-BuildAndPublishPGONuGet-Job.yml
#

Просмотреть файл

@ -421,7 +421,7 @@ jobs:
# Re-publish signed artifacts to the fullnuget artifact.
- task: PublishBuildArtifacts@1
displayName: 'Publish artifact: FullN'
displayName: 'Publish artifact: FullNuget'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\fullnuget'
artifactName: 'FullNuget'
@ -435,7 +435,55 @@ jobs:
useReleaseTag: '$(WindowsAppSDKFinalRelease)'
prereleaseVersionTag: nightly
buildPool: $(ProjectReunionBuildPool)
${{ if eq(variables['Build.Reason'], 'Schedule') }}:
publishToMaestro: True
${{ if ne(variables['Build.Reason'], 'Schedule') }}:
publishToMaestro: ${{ parameters.PublishToMaestro }}
# Build WinAppSDK
- job: IntegrationBuild
dependsOn: ['CreateNugetPackage']
condition: succeeded()
pool: $(ProjectReunionBuildPool)
variables:
WindowsAppSDKPackageVersion: $[ dependencies.CreateNugetPackage.outputs['SetVersion.packageVersion'] ]
steps:
- template: ..\eng\common\AzurePipelinesTemplates\WindowsAppSDK-Build-Steps.yml
parameters:
BuildType: 'stable'
ArtifactName: 'FullNuget'
TransportPackages:
FoundationPackage:
Name: Microsoft.WindowsAppSDK.Foundation.TransportPackage
Version: $(WindowsAppSDKPackageVersion)
# Publish
- job: Publish
dependsOn:
- CreateNugetPackage
- IntegrationBuild
condition: succeeded()
pool: $(ProjectReunionBuildPool)
variables:
WindowsAppSDKPackageVersion: $[ dependencies.CreateNugetPackage.outputs['SetVersion.packageVersion'] ]
steps:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: FullNuget
downloadPath: '$(Build.SourcesDirectory)'
itemPattern: |
**/*.nupkg
# this mysterious guid fixes the "NuGetCommand@2 is ambiguous" error :-(
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet push to ProjectReunion.nuget.internal'
inputs:
command: 'push'
packagesToPush: '$(Build.SourcesDirectory)/FullNuget/*.nupkg;!$(Build.SourcesDirectory)/FullNuget/*.symbols.nupkg'
verbosityPush: 'Detailed'
nuGetFeedType: 'internal'
#Note: The project qualifier is always required when using a feed name. Also, do not use organization scoped feeds.
publishVstsFeed: 'ProjectReunion/Project.Reunion.nuget.internal'
- ${{ if or(eq(variables['Build.Reason'], 'Schedule'), eq(parameters.publishToMaestro, 'true')) }}:
- template: ..\..\eng\common\AzurePipelinesTemplates\Maestro-PublishBuildToMaestro-Steps.yml
parameters:
AssetName: 'Microsoft.WindowsAppSDK.Foundation.TransportPackage'
AssetVersion: $(WindowsAppSDKPackageVersion)
TriggerSubscription: true

Просмотреть файл

@ -1,7 +1,16 @@
# Parameters:
# AssetNames and AssetVersions can be separated by ';' for publishing build with multiple assets
# The lengths when split by ';' must match between both of these parameters
# Example:
# AssetNames: "PackageName1;PackageName2"
# AssetVersions: "1.1;1.2"
#
# TriggerSubscription will publish the build to the default channel.
parameters:
AssetName: ''
AssetVersion: ''
AssetNames: ''
AssetVersions: ''
TriggerSubscription: false
BranchTag: ''
steps:
- task: PowerShell@2
@ -22,15 +31,34 @@ steps:
$jsonBase = @{}
$branchTag = ''
if ('${{ parameters.BranchTag }}' -ne '')
{
$branchTag = "-${{ parameters.BranchTag }}"
}
$assetNames = '${{ parameters.AssetNames }}'.Split(";")
$assetVersions = '${{ parameters.AssetVersions }}'.Split(";")
if ($assetNames.length -ne $assetVersions.length)
{
Write-Host "AssetNames and AssetVersions must have equal lengths"
Write-Host "##vso[task.complete result=Failed;]DONE"
exit 1
}
$assetList = New-Object System.Collections.ArrayList
$assetList.Add(
@{
"name"="${{ parameters.AssetName }}";
"version"="${{ parameters.AssetVersion }}";
"nonShipping"=$false;
"locations"=$null
}
)
for ($i = 0; $i -lt ($assetNames.length); $i += 1)
{
$assetList.Add(
@{
"name"=$assetNames[$i];
"version"=$assetVersions[$i];
"nonShipping"=$false;
"locations"=$null
}
)
}
# These fields below are unused but can be enabled in the future
# $locationList = New-Object System.Collections.ArrayList
@ -74,9 +102,9 @@ steps:
"azureDevOpsProject"="$(System.TeamProject)";
"azureDevOpsBuildNumber"="$(Build.BuildNumber)";
"azureDevOpsRepository"=$azureDevOpsRepo;
"azureDevOpsBranch"="$(Build.SourceBranch)";
"azureDevOpsBranch"="$(Build.SourceBranch)$branchTag";
"gitHubRepository"=$gitHubRepo;
"gitHubBranch"="$(Build.SourceBranch)";
"gitHubBranch"="$(Build.SourceBranch)$branchTag";
"released"=$true;
"stable"=$true
"incoherencies"=$null;
@ -101,6 +129,12 @@ steps:
script: |
. .\eng\common\Scripts\MaestroHelpers.ps1
$branchTag = ''
if ('${{ parameters.BranchTag }}' -ne '')
{
$branchTag = "-${{ parameters.BranchTag }}"
}
$repository = '$(Build.Repository.Uri)'
if (!(IsGitHubRepo($repository)))
{
@ -112,7 +146,7 @@ steps:
# Get the id of the default channel of this branch
$api = "/api/default-channels"
$queryParam = "&repository=" + $repository + "&branch=$(Build.SourceBranch)"
$queryParam = "&repository=" + $repository + "&branch=$(Build.SourceBranch)$branchTag"
$response = &".\eng\common\Scripts\MaestroGetRequest.ps1" -url '$(MaestroUri)' -Token '$(MaestroToken)' -api $api -queryParameters $queryParam
$jsonObj = ConvertFrom-Json $response.Content
$channelId = $jsonObj.channel.id

Просмотреть файл

@ -0,0 +1,89 @@
# This yml template checkouts the ProjectReunionInternal repository and builds the
# WindowsAppSDK based on the version.details.xml of the checkouted repository.
# This versions provided in "TransportPackages" parameter of the yml will replace the
# versions in the checkouted version.details.xml based on the name.
#
# Requirements:
# - This yml template can only be called in the "microsoft" AzureDevOps
# - Access to ProjectReunionCerts keyvault
# - Access to ProjectReunion Internal feed
#
# The intended use of this yml template is for the feeder repos' pipeline to build the WinAppSDK package
# with the latest versions from ProjectReunionInternal with the latest version of the transport package it
# has just built
#
# The WindowsAppSDK Nuget package produced will be published to WindowsAppSDKNugetPackage build artifacts
parameters:
- name: BuildType
displayName: "Build Type"
type: string
default: 'stable'
values:
- 'stable'
- 'experimental'
- name: ArtifactName
type: string
default: ''
- name: "TransportPackages"
displayName: "TransportPackages to replace (name:version)"
type: object
default:
Foundation:
name: Microsoft.WindowsAppSDK.Foundation.TransportPackage
version: 1.0.0-stable
steps:
- task: AzureKeyVault@1
inputs:
azureSubscription: 'ProjectReunion Resource Manager'
KeyVaultName: 'ProjectReunionCerts'
SecretsFilter: 'TestMSCert'
RunAsPreJob: false
- checkout: git://ProjectReunion/ProjectReunionInternal
- task: DownloadBuildArtifacts@0
inputs:
artifactName: ${{ parameters.ArtifactName }}
downloadPath: '$(Build.SourcesDirectory)\build\packages'
itemPattern: |
**/*.nupkg
# Replace the versions in version.details.xml in the ProjectReunionInternal repo
# Please note, the UpdateVersionDetailsConfig.ps1 that is used is one from the ProjectReunionInternal repo
- ${{ each package in parameters.TransportPackages }}:
- task: Powershell@2
inputs:
filePath: '$(Build.SourcesDirectory)\eng\common\Scripts\UpdateVersionDetailsConfig.ps1'
arguments: -dependencyName '${{ package.value.Name }}' -dependencyVersion '${{ package.value.Version }}'
# Setup for MyCert.pfx
- task: PowerShell@2
name: CreateCert
displayName: Create MyCert.pfx
inputs:
targetType: 'inline'
script: |
$kvSecretBytes = [System.Convert]::FromBase64String("$(TestMSCert)")
$certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
$certCollection.Import($kvSecretBytes,$null,[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
$certificateBytes = $certCollection.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12)
$pfxPath = (Join-Path $env:Build_SourcesDirectory 'MyCert.pfx')
[System.IO.File]::WriteAllBytes($pfxPath, $certificateBytes)
- task: NuGetAuthenticate@0
inputs:
nuGetServiceConnections: 'ProjectReunionInternal'
- task: PowerShell@2
name: BuildAll
displayName: BuildAll
inputs:
filePath: 'BuildAll.ps1'
arguments: -WindowsAppSDKPackageVersion "" -BuildType ${{ parameters.BuildType }} -Checkpoint "none" -Platform "x86,x64,arm64" -Configuration "release,debug"
- task: PublishBuildArtifacts@1
displayName: 'Publish Windows App SDK Packages'
inputs:
PathtoPublish: '$(Build.SourcesDirectory)\PackLocation'
artifactName: 'WindowsAppSDKNugetPackage'

Просмотреть файл

@ -0,0 +1,34 @@
[CmdLetBinding()]
Param(
[string]$dependencyName,
[string]$dependencyVersion
)
Write-Host $dependencyName
Write-Host $dependencyVersion
# Get the root of the repo.
$scriptFullPath = (split-path -parent $MyInvocation.MyCommand.Definition)
$engPath = (split-path -parent (split-path -parent $scriptFullPath))
Function CheckFile($filename)
{
if(-not (Test-Path $filename))
{
write-host "File not found: $filename"
exit 1
}
}
$configFilename = "$engPath\Version.Details.xml"
CheckFile $configFilename
# Load the build.config, update the requested version entry, then write it back out
$xmldoc = [System.Xml.XmlDocument](Get-Content $configFilename)
Write-Host $xmldoc
$node = $xmldoc.Dependencies.ProductDependencies.Dependency | ?{$_.Name -eq $dependencyName}
$node.Version = $dependencyVersion
$xmldoc.Save($configFilename)
Write-Host "Updated $configFilename"