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-11-11 21:04:54 +01:00
|
|
|
- task: DownloadPipelineArtifact@2
|
2020-08-14 01:09:50 +02:00
|
|
|
inputs:
|
2020-11-11 21:04:54 +01:00
|
|
|
source: specific
|
2020-08-14 01:09:50 +02:00
|
|
|
project: PowerShellCore
|
2020-11-11 21:04:54 +01:00
|
|
|
pipeline: '696'
|
|
|
|
preferTriggeringPipeline: true
|
|
|
|
runVersion: latestFromBranch
|
|
|
|
runBranch: '$(Build.SourceBranch)'
|
|
|
|
artifact: finalResults
|
|
|
|
patterns: '**/*.nupkg'
|
|
|
|
path: '$(Pipeline.Workspace)/releasePipeline/finalResults'
|
2020-08-14 01:09:50 +02:00
|
|
|
|
|
|
|
- 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
|
|
|
|
|
2020-11-06 01:34:51 +01:00
|
|
|
#Install-Dotnet -Channel "$Channel" -Version $sdkVersion
|
|
|
|
Start-PSBootstrap
|
2020-08-14 01:09:50 +02:00
|
|
|
|
|
|
|
Write-Verbose -Message "Installing .NET SDK completed." -Verbose
|
|
|
|
|
|
|
|
displayName: Install .NET
|
|
|
|
|
|
|
|
- pwsh: |
|
2020-11-11 21:04:54 +01:00
|
|
|
$branch = $ENV:BUILD_SOURCEBRANCH
|
2020-08-14 01:09:50 +02:00
|
|
|
$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
|