2020-08-14 01:09:50 +02:00
|
|
|
parameters:
|
|
|
|
jobName: ""
|
|
|
|
displayName: ""
|
|
|
|
imageName: ""
|
|
|
|
globalToolExeName: 'pwsh.exe'
|
|
|
|
globalToolPackageName: 'PowerShell.Windows.x64'
|
|
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
- job: ${{ parameters.jobName }}
|
|
|
|
displayName: ${{ parameters.displayName }}
|
|
|
|
pool:
|
|
|
|
vmImage: ${{ parameters.imageName }}
|
|
|
|
steps:
|
2020-10-23 20:42:24 +02:00
|
|
|
- checkout: self
|
|
|
|
clean: true
|
|
|
|
|
2020-08-14 01:09:50 +02:00
|
|
|
- download: releasePipeline
|
|
|
|
artifact: finalResults
|
|
|
|
patterns: '**/*.nupkg'
|
|
|
|
|
|
|
|
- task: DownloadBuildArtifacts@0
|
|
|
|
inputs:
|
|
|
|
buildType: specific
|
|
|
|
project: PowerShellCore
|
|
|
|
pipeline: Co-ordinated Build Test
|
|
|
|
specificBuildWithTriggering: true
|
|
|
|
buildVersionToDownload: latest
|
|
|
|
downloadType: single
|
|
|
|
artifactName: finalResults
|
|
|
|
downloadPath: '$(Pipeline.Workspace)'
|
|
|
|
itemPattern: '*.nupkg'
|
|
|
|
|
|
|
|
- pwsh: |
|
|
|
|
$dotnetMetadataPath = "$(Build.SourcesDirectory)/DotnetRuntimeMetadata.json"
|
|
|
|
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json
|
|
|
|
|
|
|
|
# Channel is like: $Channel = "5.0.1xx-preview2"
|
|
|
|
$Channel = $dotnetMetadataJson.sdk.channel
|
|
|
|
|
|
|
|
$sdkVersion = (Get-Content "$(Build.SourcesDirectory)/global.json" -Raw | ConvertFrom-Json).sdk.version
|
|
|
|
Import-Module "$(Build.SourcesDirectory)/build.psm1" -Force
|
|
|
|
|
|
|
|
Find-Dotnet
|
|
|
|
|
|
|
|
if(-not (Get-PackageSource -Name 'dotnet5' -ErrorAction SilentlyContinue))
|
|
|
|
{
|
|
|
|
$nugetFeed = ([xml](Get-Content $(Build.SourcesDirectory)/nuget.config -Raw)).Configuration.packagesources.add | Where-Object { $_.Key -eq 'dotnet5' } | Select-Object -ExpandProperty Value
|
|
|
|
Register-PackageSource -Name 'dotnet5' -Location $nugetFeed -ProviderName NuGet
|
|
|
|
Write-Verbose -Message "Register new package source 'dotnet5'" -verbose
|
|
|
|
}
|
|
|
|
|
|
|
|
## Install latest version from the channel
|
|
|
|
|
|
|
|
Install-Dotnet -Channel "$Channel" -Version $sdkVersion
|
|
|
|
|
|
|
|
Write-Verbose -Message "Installing .NET SDK completed." -Verbose
|
|
|
|
|
|
|
|
displayName: Install .NET
|
|
|
|
|
|
|
|
- pwsh: |
|
|
|
|
$branch = $ENV:RESOURCES_PIPELINE_RELEASEPIPELINE_SOURCEBRANCH
|
|
|
|
$version = $branch -replace '^.*(release[-/])v'
|
|
|
|
$vstsCommandString = "vso[task.setvariable variable=PowerShellVersion]$version"
|
|
|
|
Write-Verbose -Message "Version is $version" -Verbose
|
|
|
|
Write-Host -Object "##$vstsCommandString"
|
|
|
|
displayName: Set PowerShell Version
|
|
|
|
|
|
|
|
- pwsh: |
|
|
|
|
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
|
|
|
Import-Module "$(Build.SourcesDirectory)/build.psm1" -Force
|
|
|
|
Start-PSBootstrap -Force
|
|
|
|
|
|
|
|
$toolPath = New-Item -ItemType Directory "$(System.DefaultWorkingDirectory)/toolPath" | Select-Object -ExpandProperty FullName
|
|
|
|
|
|
|
|
dotnet tool install --add-source "$ENV:PIPELINE_WORKSPACE/releasePipeline/finalResults" --tool-path $toolPath --version '$(PowerShellVersion)' '${{ parameters.globalToolPackageName }}'
|
|
|
|
|
|
|
|
Get-ChildItem -Path $toolPath
|
|
|
|
|
|
|
|
displayName: Install global tool
|
|
|
|
|
|
|
|
- pwsh: |
|
|
|
|
$toolPath = "$(System.DefaultWorkingDirectory)/toolPath/${{ parameters.globalToolExeName }}"
|
|
|
|
|
|
|
|
if (-not (Test-Path $toolPath))
|
|
|
|
{
|
|
|
|
throw "Tool is not installed at $toolPath"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Write-Verbose -Verbose "Tool found at: $toolPath"
|
|
|
|
}
|
|
|
|
displayName: Validate tool is installed
|
|
|
|
|
|
|
|
- pwsh: |
|
|
|
|
Import-Module "$(Build.SourcesDirectory)/build.psm1" -Force
|
|
|
|
Start-PSBootstrap -Force
|
|
|
|
|
|
|
|
$exeName = if ($IsWindows) { "pwsh.exe" } else { "pwsh" }
|
|
|
|
|
|
|
|
$toolPath = "$(System.DefaultWorkingDirectory)/toolPath/${{ parameters.globalToolExeName }}"
|
|
|
|
|
|
|
|
$versionFound = & $toolPath -c '$PSVersionTable.PSVersion.ToString()'
|
|
|
|
|
|
|
|
if ( '$(PowerShellVersion)' -ne $versionFound)
|
|
|
|
{
|
|
|
|
throw "Expected version of global tool not found. Installed version is $versionFound"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
write-verbose -verbose "Found expected version: $versionFound"
|
|
|
|
}
|
|
|
|
|
|
|
|
$dateYear = & $toolPath -c '(Get-Date).Year'
|
|
|
|
|
|
|
|
if ( $dateYear -ne [DateTime]::Now.Year)
|
|
|
|
{
|
|
|
|
throw "Get-Date returned incorrect year: $dateYear"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
write-verbose -verbose "Got expected year: $dateYear"
|
|
|
|
}
|
|
|
|
displayName: Basic validation
|