Add nuget package test solution to the PR/CI build (#87)

Also factor out repetitive yml into a template.

This adds jobs to the PR and CI builds that take the just-built nuget package and then build the MUXReleaseTest solution with that new nuget package.
This commit is contained in:
Jevan Saks 2018-12-18 11:27:32 -08:00 коммит произвёл GitHub
Родитель ace0afebc3
Коммит 3cb3c0fde2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 285 добавлений и 97 удалений

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

@ -0,0 +1,43 @@
parameters:
solutionPath: ''
nugetConfigPath: ''
buildOutputDir: '$(Build.SourcesDirectory)\BuildOutput'
appxPackageDir: '$(build.artifactStagingDirectory)\$(buildConfiguration)\$(buildPlatform)\AppxPackages'
steps:
- script: |
echo parameters.solutionPath = '${{ parameters.solutionPath }}'
echo parameters.nugetConfigPath = '${{ parameters.nugetConfigPath }}'
echo parameters.appxPackageDir = '${{ parameters.appxPackageDir }}'
echo parameters.buildOutputDir = '${{ parameters.buildOutputDir }}'
displayName: 'BuildProject: Display parameters'
- task: CmdLine@1
displayName: 'Display build machine environment variables'
inputs:
filename: 'set'
- task: powershell@2
inputs:
targetType: filePath
filePath: build\Install-WindowsSdkISO.ps1
arguments: 17763
displayName: 'Install RS5 SDK (17763)'
- template: MUX-InstallNuget-Steps.yml
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet restore ${{ parameters.solutionPath }}'
inputs:
restoreSolution: ${{ parameters.solutionPath }}
feedsToUse: config
nugetConfigPath: ${{ parameters.nugetConfigPath }}
- task: VSBuild@1
displayName: 'Build solution ${{ parameters.solutionPath }}'
inputs:
solution: ${{ parameters.solutionPath }}
vsVersion: 15.0
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:AppxPackageDir="${{ parameters.appxPackageDir }}" /p:AppxBundle=Never /p:AppxSymbolPackageEnabled=false'

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

@ -0,0 +1,56 @@
parameters:
# Extract the build revision number from Build.BuildNumber. This is needed to pass to build-nupkg
jobName: ''
dependsOn: ''
buildOutputDir: '$(Build.SourcesDirectory)\BuildOutput'
nupkgdir: '$(build.artifactStagingDirectory)'
# The "primary" build arch is the one that the nuspec gets its winmd, pri, and other neutral files from
primaryBuildArch: x86
buildFlavor: Release
jobs:
- job: ${{ parameters.jobName }}
dependsOn:
- ${{ parameters.dependsOn }}
steps:
# Extract the build revision number from Build.BuildNumber. This is needed to pass to build-nupkg
- powershell: |
$revision = $env:BUILD_BUILDNUMBER.substring($env:BUILD_BUILDNUMBER.length - 3, 3)
Write-Host "##vso[task.setvariable variable=buildrevision]$revision"
displayName: 'Get build revision number'
- script: |
echo parameters.jobName '${{ parameters.jobName }}'
echo parameters.buildOutputDir '${{ parameters.buildOutputDir }}'
echo parameters.nupkgdir '${{ parameters.nupkgdir }}'
echo parameters.publishPath '${{ parameters.publishPath }}'
echo buildrevision=$(buildrevision)
displayName: 'CreateNugetPackage: Display parameters'
- task: DownloadBuildArtifacts@0
inputs:
artifactName: drop
downloadPath: '$(Build.SourcesDirectory)\Artifacts'
- template: MUX-InstallNuget-Steps.yml
- task: powershell@2
displayName: 'build-nupkg.ps1'
inputs:
targetType: filePath
filePath: build\NuSpecs\build-nupkg.ps1
arguments: >
-BuildOutput '$(Build.SourcesDirectory)\Artifacts\drop'
-OutputDir '${{ parameters.nupkgdir }}'
-prereleaseversion prerelease
-Subversion '$(buildrevision)'
-SkipFrameworkPackage
-BuildArch ${{ parameters.primaryBuildArch }}
-BuildFlavor ${{ parameters.buildFlavor }}
- task: PublishBuildArtifacts@1
displayName: 'Publish artifact: nupkg'
inputs:
PathtoPublish: '${{ parameters.nupkgdir }}'
artifactName: 'drop'

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

@ -0,0 +1,8 @@
parameters:
nugetVersion: 4.9.1
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet ${{ parameters.nugetVersion }}'
inputs:
versionSpec: ${{ parameters.nugetVersion }}

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

@ -0,0 +1,91 @@
parameters:
dependsOn: ''
useNupkgFromArtifacts: false
nugetConfigPath: test\MUXControlsReleaseTest\nuget.config
matrix:
Debug_x86:
buildPlatform: 'x86'
buildConfiguration: 'Debug'
jobs:
- job: BuildNugetTests
dependsOn:
- ${{if parameters.dependsOn }}:
- ${{ parameters.dependsOn }}
pool:
vmImage: 'VS2017-Win2016'
strategy:
maxParallel: 10
matrix: ${{ parameters.matrix }}
variables:
solutionDir: test\MUXControlsReleaseTest
solutionPath: test\MUXControlsReleaseTest\MUXControlsReleaseTest.sln
nugetConfigPath: test\MUXControlsReleaseTest\nuget.config
packageSaveDirectory: $(Build.SourcesDirectory)\packages\muxreleasetest
artifactDownloadPath: $(Build.SourcesDirectory)\Artifacts
currentPackageVersion: 2.1.181217001-prerelease
steps:
# When using the nupkg from artifacts we need to make a new nuget.config that points the MUXReleaseTest
# projects at the just-built nupkg. The MUXRelease projects use a specific nuget version so we need
# to update nuget.config to include the drop location as well as update the version in the csproj and
# packages.config for the projects.
- ${{ if eq(parameters.useNupkgFromArtifacts, 'true') }}:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: drop
downloadPath: $(artifactDownloadPath)
# Rewrite the nuget.config to use drop location.
- powershell: |
$nugetConfigFullPath = "$env:BUILD_SOURCESDIRECTORY\$env:nugetConfigPath"
@"
<?xml version='1.0' encoding='utf-8'?>
<configuration>
<packageSources>
<clear />
<add key='NuGet official package source' value='https://nuget.org/api/v2/' />
<add key='dotnetfeed' value='https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json' />
<add key='local' value='$env:artifactDownloadPath\drop'/>
</packageSources>
</configuration>
"@ | Out-File -Encoding UTF8 $nugetConfigFullPath
# Output for debugging
Write-Host (Get-Content $nugetConfigFullPath)
displayName: Rewrite nuget.config to use artifacts
# Rewrite the project files to use the new version
- powershell: |
# First, get the new version
$candidateNupkgs = Get-ChildItem $env:artifactDownloadPath\drop\Microsoft.UI.Xaml.*.nupkg
$newVersion = $candidateNupkgs[0].Name.Replace("Microsoft.UI.Xaml.", "").Replace(".nupkg", "")
Write-Host "New version: $newVersion"
$numFilesReplaced = 0
Get-ChildItem -r $env:solutionDir -File |
ForEach-Object {
$path = $_.FullName
$contents = [System.IO.File]::ReadAllText($path)
$newContents = $contents.Replace("$env:currentPackageVersion", "$newVersion")
if ($contents -ne $newContents) {
Write-Host "Updating version in $path"
$newContents | Set-Content $path -Encoding UTF8
$numFilesReplaced += 1
}
}
if ($numFilesReplaced -eq 0)
{
Write-Host "##vso[task.logissue type=error]No files found with '$env:currentPackageVersion' in them, make sure to update *.yml files when retargeting ReleaseTest projects"
Exit 1
}
displayName: Rewrite project files to use new version
- template: MUX-BuildProject-Steps.yml
parameters:
solutionPath: $(solutionPath)
nugetConfigPath: $(nugetConfigPath)

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

@ -24,42 +24,21 @@ jobs:
buildConfiguration: 'Release'
variables:
appxPackageDir: '$(build.artifactStagingDirectory)\$(buildConfiguration)\$(buildPlatform)\AppxPackages'
buildOutputDir: '$(Build.SourcesDirectory)\BuildOutput'
- name: appxPackageDir
value: $(build.artifactStagingDirectory)\$(buildConfiguration)\$(buildPlatform)\AppxPackages
- name: buildOutputDir
value: $(Build.SourcesDirectory)\BuildOutput
- name: publishDir
value: $(Build.ArtifactStagingDirectory)
steps:
- task: CmdLine@1
displayName: 'Display build machine environment variables'
inputs:
filename: 'set'
- task: powershell@2
displayName: 'Install RS5 SDK (17763)'
inputs:
targetType: filePath
filePath: build\Install-WindowsSdkISO.ps1
arguments: 17763
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.9.1'
inputs:
versionSpec: 4.9.1
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet restore MUXControls.sln'
inputs:
restoreSolution: MUXControls.sln
feedsToUse: config
- template: AzurePipelinesTemplates\MUX-BuildProject-Steps.yml
parameters:
solutionPath: MUXControls.sln
nugetConfigPath: nuget.config
- task: VSBuild@1
displayName: 'Build solution MUXControls.sln'
inputs:
solution: MUXControls.sln
vsVersion: 15.0
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:AppxPackageDir="$(appxPackageDir)" /p:AppxBundle=Never /p:AppxSymbolPackageEnabled=false'
appxPackageDir: $(appxPackageDir)
buildOutputDir: $(buildOutputDir)
publishDir: $(publishDir)
- task: powershell@2
displayName: 'Copy files to staging dir'
@ -74,39 +53,27 @@ jobs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
# Create Nuget Package
- template: AzurePipelinesTemplates\MUX-CreateNugetPackage-Job.yml
parameters:
jobName: CreateNugetPackage
dependsOn: Build
- job: CreateNuGet
dependsOn:
- Build
variables:
nupkgdir: '$(build.artifactStagingDirectory)'
buildOutputDir: '$(Build.SourcesDirectory)\BuildOutput'
steps:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: drop
downloadPath: '$(buildOutputDir)'
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.9.1'
inputs:
versionSpec: 4.9.1
# Extract the build revision number from Build.BuildNumber. This is needed to pass to build-nupkg
- powershell: |
$revision = $env:BUILD_BUILDNUMBER.substring($env:BUILD_BUILDNUMBER.length - 3, 3)
Write-Host "##vso[task.setvariable variable=buildrevision]$revision"
displayName: 'Get build revision number'
- task: powershell@2
displayName: 'build-nupkg.ps1'
inputs:
targetType: filePath
filePath: build\NuSpecs\build-nupkg.ps1
arguments: -BuildOutput '$(buildOutputDir)\drop' -OutputDir '$(nupkgdir)' -prereleaseversion prerelease -Subversion '$(buildrevision)' -SkipFrameworkPackage
- task: PublishBuildArtifacts@1
displayName: 'Publish artifact: nupkg'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
# Build solution that depends on nuget package
- template: AzurePipelinesTemplates\MUX-NugetReleaseTest-Job.yml
parameters:
dependsOn: CreateNugetPackage
useNupkgFromArtifacts: true
matrix:
Debug_x86:
buildPlatform: 'x86'
buildConfiguration: 'Debug'
Debug_x64:
buildPlatform: 'x64'
buildConfiguration: 'Debug'
Release_x64:
buildPlatform: 'x64'
buildConfiguration: 'Release'
Release_arm:
buildPlatform: 'arm'
buildConfiguration: 'Release'

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

@ -0,0 +1,4 @@
name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr)
jobs:
- template: AzurePipelinesTemplates\MUX-NugetReleaseTest-Job.yml

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

@ -14,30 +14,52 @@ jobs:
buildPlatform: 'x64'
buildConfiguration: 'Release'
variables:
- name: appxPackageDir
value: $(build.artifactStagingDirectory)\$(buildConfiguration)\$(buildPlatform)\AppxPackages
- name: buildOutputDir
value: $(Build.SourcesDirectory)\BuildOutput
- name: publishDir
value: $(Build.ArtifactStagingDirectory)
steps:
- template: AzurePipelinesTemplates\MUX-BuildProject-Steps.yml
parameters:
solutionPath: MUXControls.sln
nugetConfigPath: nuget.config
appxPackageDir: $(appxPackageDir)
buildOutputDir: $(buildOutputDir)
publishDir: $(publishDir)
- task: powershell@2
displayName: 'Copy files to staging dir'
inputs:
targetType: filePath
filePath: build\Install-WindowsSdkISO.ps1
arguments: 17763
displayName: 'Install RS5 SDK (17763)'
filePath: build\CopyFilesToStagingDir.ps1
arguments: -BuildOutputDir '$(buildOutputDir)' -PublishDir '$(publishDir)' -Platform '$(buildPlatform)' -Configuration '$(buildConfiguration)'
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.9.1'
- task: PublishBuildArtifacts@1
displayName: 'Publish artifact: drop'
inputs:
versionSpec: 4.9.1
PathtoPublish: '$(publishDir)'
artifactName: 'drop'
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet restore MUXControls.sln'
inputs:
restoreSolution: MUXControls.sln
feedsToUse: config
nugetConfigPath: nuget.config
# Create Nuget Package
- template: AzurePipelinesTemplates\MUX-CreateNugetPackage-Job.yml
parameters:
jobName: CreateNugetPackage
dependsOn: Build
primaryBuildArch: x64
- task: VSBuild@1
displayName: 'Build solution MUXControls.sln'
inputs:
solution: MUXControls.sln
vsVersion: 15.0
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
# Build solution that depends on nuget package
- template: AzurePipelinesTemplates\MUX-NugetReleaseTest-Job.yml
parameters:
dependsOn: CreateNugetPackage
useNupkgFromArtifacts: true
matrix:
Debug_x64:
buildPlatform: 'x64'
buildConfiguration: 'Debug'
Release_x64:
buildPlatform: 'x64'
buildConfiguration: 'Release'

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

@ -148,7 +148,7 @@
<Version>6.1.7</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.0.180916002-prerelease</Version>
<Version>2.1.181217001-prerelease</Version>
</PackageReference>
<PackageReference Include="MUXCustomBuildTasks">
<Version>1.0.38</Version>
@ -167,9 +167,6 @@
</Target>
-->
<Import Project="$(MSBuildProjectDirectory)\..\..\..\CustomInlineTasks.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\CustomTasks.1.0.13\build\CustomTasks.targets" Condition="Exists('..\packages\CustomTasks.1.0.13\build\CustomTasks.targets')" />
</ImportGroup>
<Target Name="AfterBuild">
<RunPowershellScript Path="$(SolutionDir)\tools\ExtractPackageDependencies_ReleaseTest.ps1" Parameters="-sourceFile $(OutDir)\$(AppxPackageName).build.appxrecipe -platform $(PlatformName) -outputFile $(AppxPackageTestDir)\$(AppxPackageName).dependencies.txt" FilesWritten="$(AppxPackageTestDir)\$(AppxPackageName).dependencies.txt" />
</Target>

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

@ -195,12 +195,12 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.UI.Xaml.2.0.180916002-prerelease\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.UI.Xaml.2.0.180916002-prerelease\build\native\Microsoft.UI.Xaml.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.UI.Xaml.2.1.181217001-prerelease\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.UI.Xaml.2.1.181217001-prerelease\build\native\Microsoft.UI.Xaml.targets'))" />
<Error Condition="!Exists('..\packages\MUXCustomBuildTasks.1.0.38\build\native\MUXCustomBuildTasks.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MUXCustomBuildTasks.1.0.38\build\native\MUXCustomBuildTasks.targets'))" />
</Target>
<Import Project="$(MSBuildProjectDirectory)\..\..\..\CustomInlineTasks.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.UI.Xaml.2.0.180916002-prerelease\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\packages\Microsoft.UI.Xaml.2.0.180916002-prerelease\build\native\Microsoft.UI.Xaml.targets')" />
<Import Project="..\packages\Microsoft.UI.Xaml.2.1.181217001-prerelease\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\packages\Microsoft.UI.Xaml.2.1.181217001-prerelease\build\native\Microsoft.UI.Xaml.targets')" />
<Import Project="..\packages\MUXCustomBuildTasks.1.0.38\build\native\MUXCustomBuildTasks.targets" Condition="Exists('..\packages\MUXCustomBuildTasks.1.0.38\build\native\MUXCustomBuildTasks.targets')" />
</ImportGroup>
<Target Name="AfterBuild">

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.NETCore.UniversalWindowsPlatform" version="6.1.7" targetFramework="native" />
<package id="Microsoft.UI.Xaml" version="2.0.180916002-prerelease" targetFramework="native" />
<package id="Microsoft.UI.Xaml" version="2.1.181217001-prerelease" targetFramework="native" />
<package id="MUXCustomBuildTasks" version="1.0.38" targetFramework="native" />
</packages>

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

@ -56,7 +56,7 @@ echo ++++++++++++++++ ----------- ++++++++++++++++++++++++
pushd %~dp0\..\build\NuSpecs
set NUGETCMD=\\edge-svcs\nuget\v3.5\nuget.exe
set NUGETCMD=%~dp0\NugetWrapper.cmd
set BUILDOUTPUT=%XES_DFSDROP%
set OUTPUTDIR=%BUILD_BINARIESDIRECTORY%\PostBuild
set ECHOON=1