[release/v7.4]Add UseDotnet task for installing dotnet (#25080)

Co-authored-by: Aditya Patwardhan <adityap@microsoft.com>
This commit is contained in:
Travis Plunk
2025-02-25 13:22:30 -08:00
committed by GitHub
co-authored by Aditya Patwardhan
parent 78e2a13ed9
commit 61ce3a3dcc
30 changed files with 337 additions and 188 deletions
@@ -27,7 +27,7 @@ runs:
- name: Bootstrap
run: |-
Import-Module ./build.psm1
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
shell: pwsh
- name: Capture Artifacts Directory
continue-on-error: true
+4 -1
View File
@@ -31,6 +31,10 @@ runs:
run: Get-ChildItem "${{ github.workspace }}\build\*" -Recurse
shell: pwsh
- uses: actions/setup-dotnet@v4
with:
global-json-file: .\global.json
- name: Bootstrap
shell: powershell
run: |-
@@ -50,7 +54,6 @@ runs:
if: success()
run: |-
Import-Module .\build.psm1 -force
Start-PSBootstrap
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '${{ github.workspace }}\build\psoptions.json'
$options = (Get-PSOptions)
+5
View File
@@ -77,6 +77,7 @@ jobs:
uses: actions/checkout@v4.1.0
with:
fetch-depth: 1000
- name: Build
uses: "./.github/actions/build/ci"
linux_test_unelevated_ci:
@@ -187,6 +188,10 @@ jobs:
with:
fetch-depth: '0'
- uses: actions/setup-dotnet@v4
with:
global-json-file: ./global.json
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
+1 -1
View File
@@ -174,7 +174,7 @@ jobs:
if: success() || failure()
run: |-
import-module ./build.psm1
start-psbootstrap -package
start-psbootstrap -Scenario package
shell: pwsh
ready_to_merge:
name: macos ready to merge
+6 -8
View File
@@ -61,14 +61,12 @@ jobs:
parameters:
repoRoot: '$(repoRoot)'
- pwsh: |
Import-Module .\build.psm1 -force
Start-PSBootstrap
workingDirectory: '$(repoRoot)'
retryCountOnTaskFailure: 2
displayName: 'Bootstrap'
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)"
- pwsh: |
Import-Module .\build.psm1 -force
+1 -1
View File
@@ -103,7 +103,7 @@ jobs:
Import-Module "$repoRoot/build.psm1"
Import-Module "$repoRoot/tools/packaging"
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
$psOptionsPath = "$(Pipeline.Workspace)/CoOrdinatedBuildPipeline/${unsignedDrop}/psoptions/psoptions.json"
+7 -1
View File
@@ -62,6 +62,13 @@ jobs:
AnalyzeInPipeline: true
Language: csharp
- task: UseDotNet@2
inputs:
useGlobalJson: true
workingDirectory: $(PowerShellRoot)
env:
ob_restore_phase: true
- pwsh: |
$runtime = $env:RUNTIME
@@ -75,7 +82,6 @@ jobs:
Import-Module -Name $(PowerShellRoot)/build.psm1 -Force
$buildWithSymbolsPath = New-Item -ItemType Directory -Path $(Pipeline.Workspace)/Symbols_$(Runtime) -Force
Start-PSBootstrap
$null = New-Item -ItemType Directory -Path $buildWithSymbolsPath -Force -Verbose
$ReleaseTagParam = @{}
+1 -1
View File
@@ -120,7 +120,7 @@ jobs:
Write-Verbose -Message "LTS Release: $LTS" -Verbose
}
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
$macosRuntime = "osx-$buildArch"
+8 -1
View File
@@ -39,9 +39,16 @@ jobs:
sudo chown $env:USER "$(Agent.TempDirectory)/PowerShell"
displayName: 'Create $(Agent.TempDirectory)/PowerShell'
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(PowerShellRoot)
- pwsh: |
Import-Module $(PowerShellRoot)/build.psm1 -Force
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
displayName: 'Bootstrap VM'
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
+7 -2
View File
@@ -97,12 +97,17 @@ jobs:
- task: NuGetToolInstaller@1
displayName: 'Install NuGet.exe'
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: '$(PowerShellRoot)'
- pwsh: |
Set-Location -Path '$(PowerShellRoot)'
Import-Module "$(PowerShellRoot)/build.psm1" -Force
Start-PSBootstrap -Verbose
$sharedModules = @('Microsoft.PowerShell.Commands.Management',
'Microsoft.PowerShell.Commands.Utility',
'Microsoft.PowerShell.ConsoleHost',
@@ -61,38 +61,12 @@ jobs:
Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/$artifactName" -Recurse
displayName: 'Capture Downloaded Artifacts'
- pwsh: |
$repoRoot = "$(Build.SourcesDirectory)/PowerShell"
$dotnetMetadataPath = "$repoRoot/DotnetRuntimeMetadata.json"
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json
# Channel is like: $Channel = "5.0.1xx-preview2"
$Channel = $dotnetMetadataJson.sdk.channel
$sdkVersion = (Get-Content "$repoRoot/global.json" -Raw | ConvertFrom-Json).sdk.version
Import-Module "$repoRoot/build.psm1" -Force
Find-Dotnet
if(-not (Get-PackageSource -Name 'dotnet' -ErrorAction SilentlyContinue))
{
$nugetFeed = ([xml](Get-Content $repoRoot/nuget.config -Raw)).Configuration.packagesources.add | Where-Object { $_.Key -eq 'dotnet' } | Select-Object -ExpandProperty Value
if ($nugetFeed) {
Register-PackageSource -Name 'dotnet' -Location $nugetFeed -ProviderName NuGet
Write-Verbose -Message "Register new package source 'dotnet'" -verbose
}
}
## Install latest version from the channel
#Install-Dotnet -Channel "$Channel" -Version $sdkVersion
Start-PSBootstrap
Write-Verbose -Message "Installing .NET SDK completed." -Verbose
displayName: Install .NET
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)/PowerShell"
- pwsh: |
$artifactName = '$(artifactName)'
@@ -38,44 +38,15 @@ jobs:
Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" -Recurse
displayName: 'Capture Downloaded Artifacts'
- pwsh: |
$repoRoot = "$(Build.SourcesDirectory)/PowerShell"
$dotnetMetadataPath = "$repoRoot/DotnetRuntimeMetadata.json"
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json
# Channel is like: $Channel = "5.0.1xx-preview2"
$Channel = $dotnetMetadataJson.sdk.channel
$sdkVersion = (Get-Content "$repoRoot/global.json" -Raw | ConvertFrom-Json).sdk.version
Import-Module "$repoRoot/build.psm1" -Force
Find-Dotnet
if(-not (Get-PackageSource -Name 'dotnet' -ErrorAction SilentlyContinue))
{
$nugetFeed = ([xml](Get-Content $repoRoot/nuget.config -Raw)).Configuration.packagesources.add | Where-Object { $_.Key -eq 'dotnet' } | Select-Object -ExpandProperty Value
if ($nugetFeed) {
Register-PackageSource -Name 'dotnet' -Location $nugetFeed -ProviderName NuGet
Write-Verbose -Message "Register new package source 'dotnet'" -verbose
}
}
## Install latest version from the channel
#Install-Dotnet -Channel "$Channel" -Version $sdkVersion
Start-PSBootstrap
Write-Verbose -Message "Installing .NET SDK completed." -Verbose
displayName: Install .NET
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(REPOROOT)
- pwsh: |
$repoRoot = "$(Build.SourcesDirectory)/PowerShell"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
Import-Module "$repoRoot/build.psm1" -Force
Start-PSBootstrap
$toolPath = New-Item -ItemType Directory "$(System.DefaultWorkingDirectory)/toolPath" | Select-Object -ExpandProperty FullName
@@ -109,7 +80,6 @@ jobs:
- pwsh: |
$repoRoot = "$(Build.SourcesDirectory)/PowerShell"
Import-Module "$repoRoot/build.psm1" -Force
Start-PSBootstrap -Force
$exeName = if ($IsWindows) { "pwsh.exe" } else { "pwsh" }
+6 -36
View File
@@ -46,47 +46,17 @@ jobs:
Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" -Recurse
displayName: 'Capture Downloaded Artifacts'
- pwsh: |
$repoRoot = "$(Build.SourcesDirectory)"
$dotnetMetadataPath = "$repoRoot/DotnetRuntimeMetadata.json"
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json
# Channel is like: $Channel = "5.0.1xx-preview2"
$Channel = $dotnetMetadataJson.sdk.channel
$sdkVersion = (Get-Content "$repoRoot/global.json" -Raw | ConvertFrom-Json).sdk.version
Import-Module "$repoRoot/build.psm1" -Force
Find-Dotnet
if(-not (Get-PackageSource -Name 'dotnet' -ErrorAction SilentlyContinue))
{
$nugetFeed = ([xml](Get-Content $repoRoot/nuget.config -Raw)).Configuration.packagesources.add | Where-Object { $_.Key -eq 'dotnet' } | Select-Object -ExpandProperty Value
if ($nugetFeed) {
Register-PackageSource -Name 'dotnet' -Location $nugetFeed -ProviderName NuGet
Write-Verbose -Message "Register new package source 'dotnet'" -verbose
}
}
## Install latest version from the channel
#Install-Dotnet -Channel "$Channel" -Version $sdkVersion
Start-PSBootstrap
Write-Verbose -Message "Installing .NET SDK completed." -Verbose
displayName: Install .NET
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(REPOROOT)
- pwsh: |
$repoRoot = "$(Build.SourcesDirectory)"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
Import-Module "$repoRoot/build.psm1" -Force
Start-PSBootstrap
$localLocation = "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg"
$xmlElement = @"
+12 -10
View File
@@ -30,12 +30,13 @@ jobs:
repoRoot: $(Build.SourcesDirectory)/PowerShell
ob_restore_phase: true
- pwsh: |
Import-Module $(Build.SourcesDirectory)/PowerShell/build.psm1
Start-PSBootstrap
displayName: Bootstrap
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)/PowerShell"
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
ob_restore_phase: true
- pwsh: |
@@ -97,12 +98,13 @@ jobs:
repoRoot: $(Build.SourcesDirectory)/PowerShell
ob_restore_phase: true
- pwsh: |
Import-Module $(Build.SourcesDirectory)/PowerShell/build.psm1
Start-PSBootstrap
displayName: Bootstrap
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)/PowerShell"
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
ob_restore_phase: true
- pwsh: |
@@ -63,6 +63,13 @@ jobs:
AnalyzeInPipeline: true
Language: csharp
- task: UseDotNet@2
inputs:
useGlobalJson: true
workingDirectory: $(PowerShellRoot)
env:
ob_restore_phase: true
- pwsh: |
$runtime = switch ($env:Architecture)
{
@@ -86,7 +93,7 @@ jobs:
Import-Module -Name $(PowerShellRoot)/build.psm1 -Force
$buildWithSymbolsPath = New-Item -ItemType Directory -Path $(Pipeline.Workspace)/Symbols_$(Architecture) -Force
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
$null = New-Item -ItemType Directory -Path $buildWithSymbolsPath -Force -Verbose
$ReleaseTagParam = @{}
@@ -135,7 +142,6 @@ jobs:
}
Import-Module -Name $(PowerShellRoot)/build.psm1 -Force
Start-PSBootstrap
## Build global tool
Write-Verbose -Message "Building PowerShell global tool for Windows.x64" -Verbose
@@ -229,8 +235,6 @@ jobs:
After that, we repack using Compress-Archive and rename it back to a nupkg.
#>
Import-Module -Name $(PowerShellRoot)/build.psm1 -Force
Start-PSBootstrap
$packagingStrings = Import-PowerShellDataFile "$(PowerShellRoot)\tools\packaging\packaging.strings.psd1"
$outputPath = Join-Path '$(ob_outputDirectory)' 'globaltool'
@@ -78,6 +78,13 @@ jobs:
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue
- task: UseDotNet@2
inputs:
useGlobalJson: true
workingDirectory: $(REPOROOT)
env:
ob_restore_phase: true
- pwsh: |
$msixUrl = '$(makeappUrl)'
Invoke-RestMethod -Uri $msixUrl -OutFile '$(Pipeline.Workspace)\makeappx.zip'
@@ -105,7 +112,7 @@ jobs:
Import-Module "$repoRoot\build.psm1"
Import-Module "$repoRoot\tools\packaging"
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
$signedFilesPath, $psoptionsFilePath = if ($env:RUNTIME -eq 'minsize') {
"$(Pipeline.Workspace)\CoOrdinatedBuildPipeline\drop_windows_build_windows_x64_${runtime}\$signedFolder"
@@ -146,7 +153,7 @@ jobs:
Write-Verbose -Message "LTS Release: $LTS"
}
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
$WindowsRuntime = switch ($runtime) {
'x64' { 'win7-x64' }
+7 -1
View File
@@ -13,6 +13,12 @@ jobs:
displayName: ${{ parameters.name }} packaging
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
- pwsh: |
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
displayName: Capture Environment
@@ -33,7 +39,7 @@ jobs:
- pwsh: |
Import-Module .\build.psm1
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
displayName: Bootstrap
- pwsh: |
+1 -1
View File
@@ -108,6 +108,6 @@ stages:
clean: true
- pwsh: |
import-module ./build.psm1
start-psbootstrap -package
start-psbootstrap -Scenario package
displayName: Bootstrap packaging
condition: succeededOrFailed()
+157
View File
@@ -0,0 +1,157 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
trigger:
# Batch merge builds together while a merge build is running
batch: true
branches:
include:
- master
- release*
- feature*
paths:
include:
- '*'
exclude:
- .vsts-ci/misc-analysis.yml
- .github/ISSUE_TEMPLATE/*
- .github/workflows/*
- .dependabot/config.yml
- test/perf/*
- .pipelines/*
pr:
branches:
include:
- master
- release*
- feature*
paths:
include:
- '*'
exclude:
- .dependabot/config.yml
- .github/ISSUE_TEMPLATE/*
- .github/workflows/*
- .vsts-ci/misc-analysis.yml
- tools/cgmanifest.json
- LICENSE.txt
- test/common/markdown/*
- test/perf/*
- tools/packaging/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*
- README.md
- .spelling
- .pipelines/*
variables:
GIT_CONFIG_PARAMETERS: "'core.autocrlf=false'"
DOTNET_CLI_TELEMETRY_OPTOUT: 1
POWERSHELL_TELEMETRY_OPTOUT: 1
# Avoid expensive initialization of dotnet cli, see: https://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
__SuppressAnsiEscapeSequences: 1
NugetSecurityAnalysisWarningLevel: none
nugetMultiFeedWarnLevel: none
resources:
- repo: self
clean: true
stages:
- stage: BuildWin
displayName: Build for Windows
jobs:
- template: templates/ci-build.yml
- stage: TestWin
displayName: Test PSResourceGetACR
jobs:
- job: win_test_ACR
displayName: PSResourceGet ACR Tests
pool:
vmImage: 'windows-latest'
steps:
- pwsh: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifacts'
inputs:
downloadType: specific
itemPattern: |
build/**/*
downloadPath: '$(System.ArtifactsDirectory)'
- pwsh: |
Get-ChildItem "$(System.ArtifactsDirectory)\*" -Recurse
displayName: 'Capture Artifacts Directory'
continueOnError: true
- pwsh: |
# Remove "Program Files\dotnet" from the env variable PATH, so old SDKs won't affect us.
Write-Host "Old Path:"
Write-Host $env:Path
$dotnetPath = Join-Path $env:SystemDrive 'Program Files\dotnet'
$paths = $env:Path -split ";" | Where-Object { -not $_.StartsWith($dotnetPath) }
$env:Path = $paths -join ";"
Write-Host "New Path:"
Write-Host $env:Path
# Bootstrap
Import-Module .\tools\ci.psm1
Invoke-CIInstall
displayName: Bootstrap
- pwsh: |
Install-Module -Name 'Microsoft.PowerShell.SecretManagement' -force -SkipPublisherCheck -AllowClobber
Install-Module -Name 'Microsoft.PowerShell.SecretStore' -force -SkipPublisherCheck -AllowClobber
$vaultPassword = ConvertTo-SecureString $("a!!"+ (Get-Random -Maximum ([int]::MaxValue))) -AsPlainText -Force
Set-SecretStoreConfiguration -Authentication None -Interaction None -Confirm:$false -Password $vaultPassword
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
displayName: 'Install Secret store'
- task: AzurePowerShell@5
inputs:
azureSubscription: PSResourceGetACR
azurePowerShellVersion: LatestVersion
ScriptType: InlineScript
pwsh: true
inline: |
Write-Verbose -Verbose "Getting Azure Container Registry"
Get-AzContainerRegistry -ResourceGroupName 'PSResourceGet' -Name 'psresourcegettest' | Select-Object -Property *
Write-Verbose -Verbose "Setting up secret for Azure Container Registry"
$azt = Get-AzAccessToken
$tenantId = $azt.TenantID
Set-Secret -Name $tenantId -Secret $azt.Token -Verbose
$vstsCommandString = "vso[task.setvariable variable=TenantId]$tenantId"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Setup Azure Container Registry secret'
- pwsh: |
Import-Module .\build.psm1 -force
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
$options = (Get-PSOptions)
$path = split-path -path $options.Output
$rootPath = split-Path -path $path
Expand-Archive -Path '$(System.ArtifactsDirectory)\build\build.zip' -DestinationPath $rootPath -Force
$pwshExe = Get-ChildItem -Path $rootPath -Recurse -Filter pwsh.exe | Select-Object -First 1
$outputFilePath = "$(Build.SourcesDirectory)\test\powershell\Modules\Microsoft.PowerShell.PSResourceGet\ACRTests.xml"
$cmdline = "`$env:ACRTESTS = 'true'; Invoke-Pester -Path '$(Build.SourcesDirectory)\test\powershell\Modules\Microsoft.PowerShell.PSResourceGet\Microsoft.PowerShell.PSResourceGet.Tests.ps1' -TestName 'PSResourceGet - ACR tests' -OutputFile $outputFilePath -OutputFormat NUnitXml"
Write-Verbose -Verbose "Running $cmdline"
& $pwshExe -Command $cmdline
Publish-TestResults -Title "PSResourceGet - ACR tests" -Path $outputFilePath -Type NUnit
displayName: 'PSResourceGet ACR functional tests using AzAuth'
+6
View File
@@ -57,6 +57,12 @@ jobs:
- ${{ if ne(variables['UseAzDevOpsFeed'], '') }}:
- template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
- pwsh: |
Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser
+6
View File
@@ -13,6 +13,12 @@ jobs:
displayName: ${{ parameters.name }} Test - ${{ parameters.purpose }} - ${{ parameters.tagSet }}
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
- template: ./test/nix-test-steps.yml
parameters:
purpose: ${{ parameters.purpose }}
@@ -23,6 +23,12 @@ jobs:
displayName: ${{ parameters.name }} Test - ${{ parameters.purpose }} - ${{ parameters.tagSet }}
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
- template: ./nix-test-steps.yml
parameters:
purpose: ${{ parameters.purpose }}
+7 -1
View File
@@ -54,6 +54,13 @@ jobs:
displayName: 'Capture Artifacts Directory'
continueOnError: true
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)"
# must be run frow Windows PowerShell
- powershell: |
# Remove "Program Files\dotnet" from the env variable PATH, so old SDKs won't affect us.
@@ -74,7 +81,6 @@ jobs:
- pwsh: |
Import-Module .\build.psm1 -force
Start-PSBootstrap
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
$options = (Get-PSOptions)
+7 -4
View File
@@ -93,6 +93,13 @@ stages:
displayName: Bootstrap
condition: succeededOrFailed()
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)"
- pwsh: |
Import-Module .\build.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
@@ -104,7 +111,6 @@ stages:
- pwsh: |
Import-Module .\build.psm1
Start-PSBootstrap
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose UnelevatedPesterTests -TagSet CI
@@ -113,7 +119,6 @@ stages:
- pwsh: |
Import-Module .\build.psm1
Start-PSBootstrap
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose ElevatedPesterTests -TagSet CI
@@ -122,7 +127,6 @@ stages:
- pwsh: |
Import-Module .\build.psm1
Start-PSBootstrap
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose UnelevatedPesterTests -TagSet Others
@@ -131,7 +135,6 @@ stages:
- pwsh: |
Import-Module .\build.psm1
Start-PSBootstrap
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose ElevatedPesterTests -TagSet Others
@@ -57,6 +57,13 @@ jobs:
condition: succeeded()
workingDirectory: $(repoPath)
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(repoPath)
- pwsh: |
Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser
+40 -35
View File
@@ -2219,10 +2219,12 @@ function Start-PSBootstrap {
# we currently pin dotnet-cli version, and will
# update it when more stable version comes out.
[string]$Version = $dotnetCLIRequiredVersion,
[switch]$Package,
[switch]$NoSudo,
[switch]$BuildLinuxArm,
[switch]$Force
[switch]$Force,
[Parameter(Mandatory = $true)]
[ValidateSet("Package", "DotNet", "Both")]
[string]$Scenario = "Package"
)
Write-Log -message "Installing PowerShell build dependencies"
@@ -2255,7 +2257,7 @@ function Start-PSBootstrap {
elseif ($environment.IsUbuntu18) { $Deps += "libicu60"}
# Packaging tools
if ($Package) { $Deps += "ruby-dev", "groff", "libffi-dev", "rpm", "g++", "make" }
if ($Scenario -eq 'Both' -or $Scenario -eq 'Package') { $Deps += "ruby-dev", "groff", "libffi-dev", "rpm", "g++", "make" }
# Install dependencies
# change the fontend from apt-get to noninteractive
@@ -2279,7 +2281,7 @@ function Start-PSBootstrap {
$Deps += "libicu", "openssl-libs"
# Packaging tools
if ($Package) { $Deps += "ruby-devel", "rpm-build", "groff", 'libffi-devel', "gcc-c++" }
if ($Scenario -eq 'Both' -or $Scenario -eq 'Package') { $Deps += "ruby-devel", "rpm-build", "groff", 'libffi-devel', "gcc-c++" }
$PackageManager = Get-RedHatPackageManager
@@ -2300,7 +2302,7 @@ function Start-PSBootstrap {
$Deps += "wget"
# Packaging tools
if ($Package) { $Deps += "ruby-devel", "rpmbuild", "groff", 'libffi-devel', "gcc" }
if ($Scenario -eq 'Both' -or $Scenario -eq 'Package') { $Deps += "ruby-devel", "rpmbuild", "groff", 'libffi-devel', "gcc" }
$PackageManager = "zypper --non-interactive install"
$baseCommand = "$sudo $PackageManager"
@@ -2340,7 +2342,7 @@ function Start-PSBootstrap {
}
# Install [fpm](https://github.com/jordansissel/fpm)
if ($Package) {
if ($Scenario -eq 'Both' -or $Scenario -eq 'Package') {
Install-GlobalGem -Sudo $sudo -GemName "dotenv" -GemVersion "2.8.1"
Install-GlobalGem -Sudo $sudo -GemName "ffi" -GemVersion "1.16.3"
Install-GlobalGem -Sudo $sudo -GemName "fpm" -GemVersion "1.15.1"
@@ -2348,42 +2350,45 @@ function Start-PSBootstrap {
}
}
Write-Verbose -Verbose "Calling Find-Dotnet from Start-PSBootstrap"
if ($Scenario -eq 'DotNet' -or $Scenario -eq 'Both') {
# Try to locate dotnet-SDK before installing it
Find-Dotnet
Write-Verbose -Verbose "Calling Find-Dotnet from Start-PSBootstrap"
Write-Verbose -Verbose "Back from calling Find-Dotnet from Start-PSBootstrap"
# Try to locate dotnet-SDK before installing it
Find-Dotnet
# Install dotnet-SDK
$dotNetExists = precheck 'dotnet' $null
$dotNetVersion = [string]::Empty
if($dotNetExists) {
$dotNetVersion = Find-RequiredSDK $dotnetCLIRequiredVersion
}
Write-Verbose -Verbose "Back from calling Find-Dotnet from Start-PSBootstrap"
if(!$dotNetExists -or $dotNetVersion -ne $dotnetCLIRequiredVersion -or $Force.IsPresent) {
if($Force.IsPresent) {
Write-Log -message "Installing dotnet due to -Force."
# Install dotnet-SDK
$dotNetExists = precheck 'dotnet' $null
$dotNetVersion = [string]::Empty
if($dotNetExists) {
$dotNetVersion = Find-RequiredSDK $dotnetCLIRequiredVersion
}
elseif(!$dotNetExists) {
Write-Log -message "dotnet not present. Installing dotnet."
if(!$dotNetExists -or $dotNetVersion -ne $dotnetCLIRequiredVersion -or $Force.IsPresent) {
if($Force.IsPresent) {
Write-Log -message "Installing dotnet due to -Force."
}
elseif(!$dotNetExists) {
Write-Log -message "dotnet not present. Installing dotnet."
}
else {
Write-Log -message "dotnet out of date ($dotNetVersion). Updating dotnet."
}
$DotnetArguments = @{ Channel=$Channel; Version=$Version; NoSudo=$NoSudo }
if ($dotnetAzureFeed) {
$null = $DotnetArguments.Add("AzureFeed", $dotnetAzureFeed)
$null = $DotnetArguments.Add("FeedCredential", $dotnetAzureFeedSecret)
}
Install-Dotnet @DotnetArguments
}
else {
Write-Log -message "dotnet out of date ($dotNetVersion). Updating dotnet."
Write-Log -message "dotnet is already installed. Skipping installation."
}
$DotnetArguments = @{ Channel=$Channel; Version=$Version; NoSudo=$NoSudo }
if ($dotnetAzureFeed) {
$null = $DotnetArguments.Add("AzureFeed", $dotnetAzureFeed)
$null = $DotnetArguments.Add("FeedCredential", $dotnetAzureFeedSecret)
}
Install-Dotnet @DotnetArguments
}
else {
Write-Log -message "dotnet is already installed. Skipping installation."
}
# Install Windows dependencies if `-Package` or `-BuildWindowsNative` is specified
@@ -2395,7 +2400,7 @@ function Start-PSBootstrap {
$psInstallFile = [System.IO.Path]::Combine($PSScriptRoot, "tools", "install-powershell.ps1")
& $psInstallFile -AddToPath
}
if ($Package) {
if ($Scenario -eq 'Both' -or $Scenario -eq 'Package') {
Import-Module "$PSScriptRoot\tools\wix\wix.psm1"
$isArm64 = "$env:RUNTIME" -eq 'arm64'
Install-Wix -arm64:$isArm64
+1 -5
View File
@@ -188,8 +188,6 @@ function Invoke-CIInstall
}
Set-BuildVariable -Name TestPassed -Value False
Write-Verbose -Verbose -Message "Calling Start-PSBootstrap from Invoke-CIInstall"
Start-PSBootstrap
}
function Invoke-CIxUnit
@@ -402,8 +400,6 @@ function New-CodeCoverageAndTestPackage
if (Test-DailyBuild)
{
Start-PSBootstrap -Verbose
Start-PSBuild -Configuration 'CodeCoverage' -Clean
$codeCoverageOutput = Split-Path -Parent (Get-PSOutput)
@@ -717,7 +713,7 @@ function Invoke-BootstrapStage
Write-Log -Message "Executing ci.psm1 Bootstrap Stage"
# Make sure we have all the tags
Sync-PSTags -AddRemoteIfMissing
Start-PSBootstrap -Package:$createPackages
Start-PSBootstrap -Scenario Package:$createPackages
}
# Run pester tests for Linux and macOS
+2 -2
View File
@@ -1635,7 +1635,7 @@ function Get-PackageDependencies
function Test-Dependencies
{
foreach ($Dependency in "fpm") {
if (!(precheck $Dependency "Package dependency '$Dependency' not found. Run Start-PSBootstrap -Package")) {
if (!(precheck $Dependency "Package dependency '$Dependency' not found. Run Start-PSBootstrap -Scenario Package")) {
# These tools are not added to the path automatically on OpenSUSE 13.2
# try adding them to the path and re-tesing first
[string] $gemsPath = $null
@@ -1645,7 +1645,7 @@ function Test-Dependencies
$depenencyPath = Get-ChildItem -Path (Join-Path -Path $gemsPath -ChildPath "gems" -AdditionalChildPath $Dependency) -Recurse | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 1 -ExpandProperty DirectoryName
$originalPath = $env:PATH
$env:PATH = $ENV:PATH +":" + $depenencyPath
if ((precheck $Dependency "Package dependency '$Dependency' not found. Run Start-PSBootstrap -Package")) {
if ((precheck $Dependency "Package dependency '$Dependency' not found. Run Start-PSBootstrap -Scenario Package")) {
continue
}
else {
@@ -248,7 +248,7 @@ jobs:
- powershell: |
Import-Module "$env:POWERSHELLROOT/build.psm1"
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
displayName: 'Bootstrap'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot)
@@ -57,7 +57,7 @@ jobs:
- powershell: |
Import-Module "$env:POWERSHELLROOT/build.psm1"
Start-PSBootstrap -Package
Start-PSBootstrap -Scenario Package
displayName: 'Bootstrap'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot)