1
0
mirror of https://github.com/PowerShell/PowerShell synced 2025-10-06 00:22:59 +02:00

Add UseDotnet task for installing dotnet (#24905)

Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
This commit is contained in:
Aditya Patwardhan
2025-02-03 14:37:32 -08:00
committed by GitHub
parent 174df290e5
commit 0cf23a841a
30 changed files with 180 additions and 190 deletions

View File

@@ -27,7 +27,7 @@ runs:
- name: Bootstrap - name: Bootstrap
run: |- run: |-
Import-Module ./build.psm1 Import-Module ./build.psm1
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
shell: pwsh shell: pwsh
- name: Capture Artifacts Directory - name: Capture Artifacts Directory
continue-on-error: true continue-on-error: true

View File

@@ -31,6 +31,10 @@ runs:
run: Get-ChildItem "${{ github.workspace }}\build\*" -Recurse run: Get-ChildItem "${{ github.workspace }}\build\*" -Recurse
shell: pwsh shell: pwsh
- uses: actions/setup-dotnet@v4
with:
global-json-file: .\global.json
- name: Bootstrap - name: Bootstrap
shell: powershell shell: powershell
run: |- run: |-
@@ -50,7 +54,6 @@ runs:
if: success() if: success()
run: |- run: |-
Import-Module .\build.psm1 -force Import-Module .\build.psm1 -force
Start-PSBootstrap
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '${{ github.workspace }}\build\psoptions.json' Restore-PSOptions -PSOptionsPath '${{ github.workspace }}\build\psoptions.json'
$options = (Get-PSOptions) $options = (Get-PSOptions)

View File

@@ -74,6 +74,7 @@ jobs:
uses: actions/checkout@v4.1.0 uses: actions/checkout@v4.1.0
with: with:
fetch-depth: 1000 fetch-depth: 1000
- name: Build - name: Build
uses: "./.github/actions/build/ci" uses: "./.github/actions/build/ci"
linux_test_unelevated_ci: linux_test_unelevated_ci:
@@ -184,6 +185,10 @@ jobs:
with: with:
fetch-depth: '0' fetch-depth: '0'
- uses: actions/setup-dotnet@v4
with:
global-json-file: ./global.json
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9 uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9

View File

@@ -171,7 +171,7 @@ jobs:
if: success() || failure() if: success() || failure()
run: |- run: |-
import-module ./build.psm1 import-module ./build.psm1
start-psbootstrap -package start-psbootstrap -Scenario package
shell: pwsh shell: pwsh
ready_to_merge: ready_to_merge:
name: macos ready to merge name: macos ready to merge

View File

@@ -61,14 +61,12 @@ jobs:
parameters: parameters:
repoRoot: '$(repoRoot)' repoRoot: '$(repoRoot)'
- pwsh: | - task: UseDotNet@2
Import-Module .\build.psm1 -force displayName: 'Use .NET Core sdk'
Start-PSBootstrap inputs:
workingDirectory: '$(repoRoot)' useGlobalJson: true
retryCountOnTaskFailure: 2 packageType: 'sdk'
displayName: 'Bootstrap' workingDirectory: $(Build.SourcesDirectory)"
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
- pwsh: | - pwsh: |
Import-Module .\build.psm1 -force Import-Module .\build.psm1 -force

View File

@@ -103,7 +103,7 @@ jobs:
Import-Module "$repoRoot/build.psm1" Import-Module "$repoRoot/build.psm1"
Import-Module "$repoRoot/tools/packaging" Import-Module "$repoRoot/tools/packaging"
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
$psOptionsPath = "$(Pipeline.Workspace)/CoOrdinatedBuildPipeline/${unsignedDrop}/psoptions/psoptions.json" $psOptionsPath = "$(Pipeline.Workspace)/CoOrdinatedBuildPipeline/${unsignedDrop}/psoptions/psoptions.json"

View File

@@ -64,6 +64,13 @@ jobs:
AnalyzeInPipeline: false AnalyzeInPipeline: false
Language: csharp Language: csharp
- task: UseDotNet@2
inputs:
useGlobalJson: true
workingDirectory: $(PowerShellRoot)
env:
ob_restore_phase: true
- pwsh: | - pwsh: |
$runtime = $env:RUNTIME $runtime = $env:RUNTIME
@@ -77,7 +84,6 @@ jobs:
Import-Module -Name $(PowerShellRoot)/build.psm1 -Force Import-Module -Name $(PowerShellRoot)/build.psm1 -Force
$buildWithSymbolsPath = New-Item -ItemType Directory -Path $(Pipeline.Workspace)/Symbols_$(Runtime) -Force $buildWithSymbolsPath = New-Item -ItemType Directory -Path $(Pipeline.Workspace)/Symbols_$(Runtime) -Force
Start-PSBootstrap
$null = New-Item -ItemType Directory -Path $buildWithSymbolsPath -Force -Verbose $null = New-Item -ItemType Directory -Path $buildWithSymbolsPath -Force -Verbose
$ReleaseTagParam = @{} $ReleaseTagParam = @{}

View File

@@ -110,7 +110,7 @@ jobs:
Write-Verbose -Message "LTS Release: $LTS" Write-Verbose -Message "LTS Release: $LTS"
} }
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
$macosRuntime = "osx-$buildArch" $macosRuntime = "osx-$buildArch"

View File

@@ -39,9 +39,16 @@ jobs:
sudo chown $env:USER "$(Agent.TempDirectory)/PowerShell" sudo chown $env:USER "$(Agent.TempDirectory)/PowerShell"
displayName: 'Create $(Agent.TempDirectory)/PowerShell' displayName: 'Create $(Agent.TempDirectory)/PowerShell'
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(PowerShellRoot)
- pwsh: | - pwsh: |
Import-Module $(PowerShellRoot)/build.psm1 -Force Import-Module $(PowerShellRoot)/build.psm1 -Force
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
displayName: 'Bootstrap VM' displayName: 'Bootstrap VM'
env: env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY) __DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)

View File

@@ -97,12 +97,17 @@ jobs:
- task: NuGetToolInstaller@1 - task: NuGetToolInstaller@1
displayName: 'Install NuGet.exe' displayName: 'Install NuGet.exe'
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: '$(PowerShellRoot)'
- pwsh: | - pwsh: |
Set-Location -Path '$(PowerShellRoot)' Set-Location -Path '$(PowerShellRoot)'
Import-Module "$(PowerShellRoot)/build.psm1" -Force Import-Module "$(PowerShellRoot)/build.psm1" -Force
Start-PSBootstrap -Verbose
$sharedModules = @('Microsoft.PowerShell.Commands.Management', $sharedModules = @('Microsoft.PowerShell.Commands.Management',
'Microsoft.PowerShell.Commands.Utility', 'Microsoft.PowerShell.Commands.Utility',
'Microsoft.PowerShell.ConsoleHost', 'Microsoft.PowerShell.ConsoleHost',

View File

@@ -61,38 +61,12 @@ jobs:
Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/$artifactName" -Recurse Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/$artifactName" -Recurse
displayName: 'Capture Downloaded Artifacts' displayName: 'Capture Downloaded Artifacts'
- pwsh: | - task: UseDotNet@2
$repoRoot = "$(Build.SourcesDirectory)/PowerShell" displayName: 'Use .NET Core sdk'
$dotnetMetadataPath = "$repoRoot/DotnetRuntimeMetadata.json" inputs:
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json useGlobalJson: true
packageType: 'sdk'
# Channel is like: $Channel = "5.0.1xx-preview2" workingDirectory: $(Build.SourcesDirectory)/PowerShell"
$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)
- pwsh: | - pwsh: |
$artifactName = '$(artifactName)' $artifactName = '$(artifactName)'

View File

@@ -38,44 +38,15 @@ jobs:
Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" -Recurse Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" -Recurse
displayName: 'Capture Downloaded Artifacts' displayName: 'Capture Downloaded Artifacts'
- pwsh: | - task: UseDotNet@2
$repoRoot = "$(Build.SourcesDirectory)/PowerShell" displayName: 'Use .NET Core sdk'
$dotnetMetadataPath = "$repoRoot/DotnetRuntimeMetadata.json" inputs:
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json useGlobalJson: true
packageType: 'sdk'
# Channel is like: $Channel = "5.0.1xx-preview2" workingDirectory: $(REPOROOT)
$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)
- pwsh: | - pwsh: |
$repoRoot = "$(Build.SourcesDirectory)/PowerShell" $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 $toolPath = New-Item -ItemType Directory "$(System.DefaultWorkingDirectory)/toolPath" | Select-Object -ExpandProperty FullName
@@ -108,8 +79,6 @@ jobs:
- pwsh: | - pwsh: |
$repoRoot = "$(Build.SourcesDirectory)/PowerShell" $repoRoot = "$(Build.SourcesDirectory)/PowerShell"
Import-Module "$repoRoot/build.psm1" -Force
Start-PSBootstrap
$exeName = if ($IsWindows) { "pwsh.exe" } else { "pwsh" } $exeName = if ($IsWindows) { "pwsh.exe" } else { "pwsh" }

View File

@@ -46,47 +46,17 @@ jobs:
Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" -Recurse Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" -Recurse
displayName: 'Capture Downloaded Artifacts' displayName: 'Capture Downloaded Artifacts'
- pwsh: | - task: UseDotNet@2
$repoRoot = "$(Build.SourcesDirectory)" displayName: 'Use .NET Core sdk'
inputs:
$dotnetMetadataPath = "$repoRoot/DotnetRuntimeMetadata.json" useGlobalJson: true
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json packageType: 'sdk'
workingDirectory: $(REPOROOT)
# 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)
- pwsh: | - pwsh: |
$repoRoot = "$(Build.SourcesDirectory)" $repoRoot = "$(Build.SourcesDirectory)"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
Import-Module "$repoRoot/build.psm1" -Force
Start-PSBootstrap
$localLocation = "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" $localLocation = "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg"
$xmlElement = @" $xmlElement = @"

View File

@@ -30,12 +30,13 @@ jobs:
repoRoot: $(Build.SourcesDirectory)/PowerShell repoRoot: $(Build.SourcesDirectory)/PowerShell
ob_restore_phase: true ob_restore_phase: true
- pwsh: | - task: UseDotNet@2
Import-Module $(Build.SourcesDirectory)/PowerShell/build.psm1 displayName: 'Use .NET Core sdk'
Start-PSBootstrap inputs:
displayName: Bootstrap useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)/PowerShell"
env: env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
ob_restore_phase: true ob_restore_phase: true
- pwsh: | - pwsh: |
@@ -97,12 +98,13 @@ jobs:
repoRoot: $(Build.SourcesDirectory)/PowerShell repoRoot: $(Build.SourcesDirectory)/PowerShell
ob_restore_phase: true ob_restore_phase: true
- pwsh: | - task: UseDotNet@2
Import-Module $(Build.SourcesDirectory)/PowerShell/build.psm1 displayName: 'Use .NET Core sdk'
Start-PSBootstrap inputs:
displayName: Bootstrap useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)/PowerShell"
env: env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
ob_restore_phase: true ob_restore_phase: true
- pwsh: | - pwsh: |

View File

@@ -65,6 +65,13 @@ jobs:
AnalyzeInPipeline: false AnalyzeInPipeline: false
Language: csharp Language: csharp
- task: UseDotNet@2
inputs:
useGlobalJson: true
workingDirectory: $(PowerShellRoot)
env:
ob_restore_phase: true
- pwsh: | - pwsh: |
$runtime = switch ($env:Architecture) $runtime = switch ($env:Architecture)
{ {
@@ -88,7 +95,7 @@ jobs:
Import-Module -Name $(PowerShellRoot)/build.psm1 -Force Import-Module -Name $(PowerShellRoot)/build.psm1 -Force
$buildWithSymbolsPath = New-Item -ItemType Directory -Path $(Pipeline.Workspace)/Symbols_$(Architecture) -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 $null = New-Item -ItemType Directory -Path $buildWithSymbolsPath -Force -Verbose
$ReleaseTagParam = @{} $ReleaseTagParam = @{}
@@ -137,7 +144,6 @@ jobs:
} }
Import-Module -Name $(PowerShellRoot)/build.psm1 -Force Import-Module -Name $(PowerShellRoot)/build.psm1 -Force
Start-PSBootstrap
## Build global tool ## Build global tool
Write-Verbose -Message "Building PowerShell global tool for Windows.x64" -Verbose Write-Verbose -Message "Building PowerShell global tool for Windows.x64" -Verbose
@@ -231,8 +237,6 @@ jobs:
After that, we repack using Compress-Archive and rename it back to a nupkg. 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" $packagingStrings = Import-PowerShellDataFile "$(PowerShellRoot)\tools\packaging\packaging.strings.psd1"
$outputPath = Join-Path '$(ob_outputDirectory)' 'globaltool' $outputPath = Join-Path '$(ob_outputDirectory)' 'globaltool'

View File

@@ -78,6 +78,13 @@ jobs:
env: env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue 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: | - pwsh: |
$msixUrl = '$(makeappUrl)' $msixUrl = '$(makeappUrl)'
Invoke-RestMethod -Uri $msixUrl -OutFile '$(Pipeline.Workspace)\makeappx.zip' Invoke-RestMethod -Uri $msixUrl -OutFile '$(Pipeline.Workspace)\makeappx.zip'
@@ -105,7 +112,7 @@ jobs:
Import-Module "$repoRoot\build.psm1" Import-Module "$repoRoot\build.psm1"
Import-Module "$repoRoot\tools\packaging" Import-Module "$repoRoot\tools\packaging"
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
$signedFilesPath, $psoptionsFilePath = if ($env:RUNTIME -eq 'minsize') { $signedFilesPath, $psoptionsFilePath = if ($env:RUNTIME -eq 'minsize') {
"$(Pipeline.Workspace)\CoOrdinatedBuildPipeline\drop_windows_build_windows_x64_${runtime}\$signedFolder" "$(Pipeline.Workspace)\CoOrdinatedBuildPipeline\drop_windows_build_windows_x64_${runtime}\$signedFolder"
@@ -136,7 +143,7 @@ jobs:
Write-Verbose -Message "LTS Release: $LTS" Write-Verbose -Message "LTS Release: $LTS"
} }
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
$WindowsRuntime = switch ($runtime) { $WindowsRuntime = switch ($runtime) {
'x64' { 'win7-x64' } 'x64' { 'win7-x64' }

View File

@@ -13,6 +13,12 @@ jobs:
displayName: ${{ parameters.name }} packaging displayName: ${{ parameters.name }} packaging
steps: steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
- pwsh: | - pwsh: |
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
displayName: Capture Environment displayName: Capture Environment
@@ -33,7 +39,7 @@ jobs:
- pwsh: | - pwsh: |
Import-Module .\build.psm1 Import-Module .\build.psm1
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
displayName: Bootstrap displayName: Bootstrap
- pwsh: | - pwsh: |

View File

@@ -110,6 +110,6 @@ stages:
clean: true clean: true
- pwsh: | - pwsh: |
import-module ./build.psm1 import-module ./build.psm1
start-psbootstrap -package start-psbootstrap -Scenario package
displayName: Bootstrap packaging displayName: Bootstrap packaging
condition: succeededOrFailed() condition: succeededOrFailed()

View File

@@ -137,7 +137,6 @@ stages:
- pwsh: | - pwsh: |
Import-Module .\build.psm1 -force Import-Module .\build.psm1 -force
Start-PSBootstrap
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
$options = (Get-PSOptions) $options = (Get-PSOptions)

View File

@@ -57,6 +57,12 @@ jobs:
- ${{ if ne(variables['UseAzDevOpsFeed'], '') }}: - ${{ if ne(variables['UseAzDevOpsFeed'], '') }}:
- template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml - template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
- pwsh: | - pwsh: |
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser Invoke-CIInstall -SkipUser

View File

@@ -13,6 +13,12 @@ jobs:
displayName: ${{ parameters.name }} Test - ${{ parameters.purpose }} - ${{ parameters.tagSet }} displayName: ${{ parameters.name }} Test - ${{ parameters.purpose }} - ${{ parameters.tagSet }}
steps: steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
- template: ./test/nix-test-steps.yml - template: ./test/nix-test-steps.yml
parameters: parameters:
purpose: ${{ parameters.purpose }} purpose: ${{ parameters.purpose }}

View File

@@ -23,6 +23,12 @@ jobs:
displayName: ${{ parameters.name }} Test - ${{ parameters.purpose }} - ${{ parameters.tagSet }} displayName: ${{ parameters.name }} Test - ${{ parameters.purpose }} - ${{ parameters.tagSet }}
steps: steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
- template: ./nix-test-steps.yml - template: ./nix-test-steps.yml
parameters: parameters:
purpose: ${{ parameters.purpose }} purpose: ${{ parameters.purpose }}

View File

@@ -54,6 +54,13 @@ jobs:
displayName: 'Capture Artifacts Directory' displayName: 'Capture Artifacts Directory'
continueOnError: true continueOnError: true
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)"
# must be run frow Windows PowerShell # must be run frow Windows PowerShell
- powershell: | - powershell: |
# Remove "Program Files\dotnet" from the env variable PATH, so old SDKs won't affect us. # Remove "Program Files\dotnet" from the env variable PATH, so old SDKs won't affect us.
@@ -74,7 +81,6 @@ jobs:
- pwsh: | - pwsh: |
Import-Module .\build.psm1 -force Import-Module .\build.psm1 -force
Start-PSBootstrap
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
$options = (Get-PSOptions) $options = (Get-PSOptions)

View File

@@ -93,6 +93,13 @@ stages:
displayName: Bootstrap displayName: Bootstrap
condition: succeededOrFailed() condition: succeededOrFailed()
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(Build.SourcesDirectory)"
- pwsh: | - pwsh: |
Import-Module .\build.psm1 Import-Module .\build.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
@@ -104,7 +111,6 @@ stages:
- pwsh: | - pwsh: |
Import-Module .\build.psm1 Import-Module .\build.psm1
Start-PSBootstrap
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose UnelevatedPesterTests -TagSet CI Invoke-CITest -Purpose UnelevatedPesterTests -TagSet CI
@@ -113,7 +119,6 @@ stages:
- pwsh: | - pwsh: |
Import-Module .\build.psm1 Import-Module .\build.psm1
Start-PSBootstrap
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose ElevatedPesterTests -TagSet CI Invoke-CITest -Purpose ElevatedPesterTests -TagSet CI
@@ -122,7 +127,6 @@ stages:
- pwsh: | - pwsh: |
Import-Module .\build.psm1 Import-Module .\build.psm1
Start-PSBootstrap
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose UnelevatedPesterTests -TagSet Others Invoke-CITest -Purpose UnelevatedPesterTests -TagSet Others
@@ -131,7 +135,6 @@ stages:
- pwsh: | - pwsh: |
Import-Module .\build.psm1 Import-Module .\build.psm1
Start-PSBootstrap
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose ElevatedPesterTests -TagSet Others Invoke-CITest -Purpose ElevatedPesterTests -TagSet Others

View File

@@ -57,6 +57,13 @@ jobs:
condition: succeeded() condition: succeeded()
workingDirectory: $(repoPath) workingDirectory: $(repoPath)
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
useGlobalJson: true
packageType: 'sdk'
workingDirectory: $(repoPath)
- pwsh: | - pwsh: |
Import-Module .\tools\ci.psm1 Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser Invoke-CIInstall -SkipUser

View File

@@ -2226,10 +2226,12 @@ function Start-PSBootstrap {
# we currently pin dotnet-cli version, and will # we currently pin dotnet-cli version, and will
# update it when more stable version comes out. # update it when more stable version comes out.
[string]$Version = $dotnetCLIRequiredVersion, [string]$Version = $dotnetCLIRequiredVersion,
[switch]$Package,
[switch]$NoSudo, [switch]$NoSudo,
[switch]$BuildLinuxArm, [switch]$BuildLinuxArm,
[switch]$Force [switch]$Force,
[Parameter(Mandatory = $true)]
[ValidateSet("Package", "DotNet", "Both")]
[string]$Scenario = "Package"
) )
Write-Log -message "Installing PowerShell build dependencies" Write-Log -message "Installing PowerShell build dependencies"
@@ -2262,7 +2264,7 @@ function Start-PSBootstrap {
elseif ($environment.IsUbuntu18) { $Deps += "libicu60"} elseif ($environment.IsUbuntu18) { $Deps += "libicu60"}
# Packaging tools # 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 # Install dependencies
# change the fontend from apt-get to noninteractive # change the fontend from apt-get to noninteractive
@@ -2286,7 +2288,7 @@ function Start-PSBootstrap {
$Deps += "libicu", "openssl-libs" $Deps += "libicu", "openssl-libs"
# Packaging tools # 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 $PackageManager = Get-RedHatPackageManager
@@ -2307,7 +2309,7 @@ function Start-PSBootstrap {
$Deps += "wget" $Deps += "wget"
# Packaging tools # 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" $PackageManager = "zypper --non-interactive install"
$baseCommand = "$sudo $PackageManager" $baseCommand = "$sudo $PackageManager"
@@ -2347,7 +2349,7 @@ function Start-PSBootstrap {
} }
# Install [fpm](https://github.com/jordansissel/fpm) # 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 "dotenv" -GemVersion "2.8.1"
Install-GlobalGem -Sudo $sudo -GemName "ffi" -GemVersion "1.16.3" Install-GlobalGem -Sudo $sudo -GemName "ffi" -GemVersion "1.16.3"
Install-GlobalGem -Sudo $sudo -GemName "fpm" -GemVersion "1.15.1" Install-GlobalGem -Sudo $sudo -GemName "fpm" -GemVersion "1.15.1"
@@ -2355,42 +2357,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 Write-Verbose -Verbose "Calling Find-Dotnet from Start-PSBootstrap"
Find-Dotnet
Write-Verbose -Verbose "Back from calling Find-Dotnet from Start-PSBootstrap" # Try to locate dotnet-SDK before installing it
Find-Dotnet
# Install dotnet-SDK Write-Verbose -Verbose "Back from calling Find-Dotnet from Start-PSBootstrap"
$dotNetExists = precheck 'dotnet' $null
$dotNetVersion = [string]::Empty
if($dotNetExists) {
$dotNetVersion = Find-RequiredSDK $dotnetCLIRequiredVersion
}
if(!$dotNetExists -or $dotNetVersion -ne $dotnetCLIRequiredVersion -or $Force.IsPresent) { # Install dotnet-SDK
if($Force.IsPresent) { $dotNetExists = precheck 'dotnet' $null
Write-Log -message "Installing dotnet due to -Force." $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 { 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 # Install Windows dependencies if `-Package` or `-BuildWindowsNative` is specified
@@ -2402,7 +2407,7 @@ function Start-PSBootstrap {
$psInstallFile = [System.IO.Path]::Combine($PSScriptRoot, "tools", "install-powershell.ps1") $psInstallFile = [System.IO.Path]::Combine($PSScriptRoot, "tools", "install-powershell.ps1")
& $psInstallFile -AddToPath & $psInstallFile -AddToPath
} }
if ($Package) { if ($Scenario -eq 'Both' -or $Scenario -eq 'Package') {
Import-Module "$PSScriptRoot\tools\wix\wix.psm1" Import-Module "$PSScriptRoot\tools\wix\wix.psm1"
$isArm64 = "$env:RUNTIME" -eq 'arm64' $isArm64 = "$env:RUNTIME" -eq 'arm64'
Install-Wix -arm64:$isArm64 Install-Wix -arm64:$isArm64

View File

@@ -188,8 +188,6 @@ function Invoke-CIInstall
} }
Set-BuildVariable -Name TestPassed -Value False Set-BuildVariable -Name TestPassed -Value False
Write-Verbose -Verbose -Message "Calling Start-PSBootstrap from Invoke-CIInstall"
Start-PSBootstrap
} }
function Invoke-CIxUnit function Invoke-CIxUnit
@@ -402,8 +400,6 @@ function New-CodeCoverageAndTestPackage
if (Test-DailyBuild) if (Test-DailyBuild)
{ {
Start-PSBootstrap -Verbose
Start-PSBuild -Configuration 'CodeCoverage' -Clean Start-PSBuild -Configuration 'CodeCoverage' -Clean
$codeCoverageOutput = Split-Path -Parent (Get-PSOutput) $codeCoverageOutput = Split-Path -Parent (Get-PSOutput)
@@ -691,7 +687,7 @@ function Invoke-BootstrapStage
Write-Log -Message "Executing ci.psm1 Bootstrap Stage" Write-Log -Message "Executing ci.psm1 Bootstrap Stage"
# Make sure we have all the tags # Make sure we have all the tags
Sync-PSTags -AddRemoteIfMissing Sync-PSTags -AddRemoteIfMissing
Start-PSBootstrap -Package:$createPackages Start-PSBootstrap -Scenario Package:$createPackages
} }
# Run pester tests for Linux and macOS # Run pester tests for Linux and macOS

View File

@@ -1637,7 +1637,7 @@ function Get-PackageDependencies
function Test-Dependencies function Test-Dependencies
{ {
foreach ($Dependency in "fpm") { 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 # These tools are not added to the path automatically on OpenSUSE 13.2
# try adding them to the path and re-tesing first # try adding them to the path and re-tesing first
[string] $gemsPath = $null [string] $gemsPath = $null
@@ -1647,7 +1647,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 $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 $originalPath = $env:PATH
$env:PATH = $ENV:PATH +":" + $depenencyPath $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 continue
} }
else { else {

View File

@@ -248,7 +248,7 @@ jobs:
- powershell: | - powershell: |
Import-Module "$env:POWERSHELLROOT/build.psm1" Import-Module "$env:POWERSHELLROOT/build.psm1"
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
displayName: 'Bootstrap' displayName: 'Bootstrap'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true')) condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot) workingDirectory: $(PowerShellRoot)

View File

@@ -57,7 +57,7 @@ jobs:
- powershell: | - powershell: |
Import-Module "$env:POWERSHELLROOT/build.psm1" Import-Module "$env:POWERSHELLROOT/build.psm1"
Start-PSBootstrap -Package Start-PSBootstrap -Scenario Package
displayName: 'Bootstrap' displayName: 'Bootstrap'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true')) condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot) workingDirectory: $(PowerShellRoot)