Apply latest Library.Template scripts
This comes from https://github.com/AArnott/Library.Template.git commit c4a24d10ecf2d391cdd9d89c2652114c695f6db6
This commit is contained in:
Родитель
c2ee6bca14
Коммит
90a2b1a896
|
@ -0,0 +1 @@
|
|||
<RunSettings />
|
|
@ -0,0 +1,22 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Downloads the NuGet.exe tool and returns the path to it.
|
||||
.PARAMETER NuGetVersion
|
||||
The version of the NuGet tool to acquire.
|
||||
#>
|
||||
Param(
|
||||
[Parameter()]
|
||||
[string]$NuGetVersion='5.2.0'
|
||||
)
|
||||
|
||||
$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1"
|
||||
$binaryToolsPath = Join-Path $toolsPath $NuGetVersion
|
||||
if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath }
|
||||
$nugetPath = Join-Path $binaryToolsPath nuget.exe
|
||||
|
||||
if (!(Test-Path $nugetPath)) {
|
||||
Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow
|
||||
(New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe", $nugetPath)
|
||||
}
|
||||
|
||||
return (Resolve-Path $nugetPath).Path
|
|
@ -0,0 +1,14 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Downloads 32-bit and 64-bit procdump executables and returns the path to where they were installed.
|
||||
#>
|
||||
$version = '0.0.1'
|
||||
$baseDir = "$PSScriptRoot\..\obj\tools"
|
||||
$procDumpToolPath = "$baseDir\procdump.$version\bin"
|
||||
if (-not (Test-Path $procDumpToolPath)) {
|
||||
if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null }
|
||||
$baseDir = (Resolve-Path $baseDir).Path # Normalize it
|
||||
& (& $PSScriptRoot\Get-NuGetTool.ps1) install procdump -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://api.nuget.org/v3/index.json | Out-Null
|
||||
}
|
||||
|
||||
(Resolve-Path $procDumpToolPath).Path
|
|
@ -0,0 +1 @@
|
|||
<RunSettings />
|
|
@ -10,30 +10,70 @@
|
|||
[CmdletBinding(SupportsShouldProcess=$true)]
|
||||
Param(
|
||||
[Parameter(Mandatory=$true, Position=1)]
|
||||
$Variables
|
||||
$Variables,
|
||||
[string[]]$PrependPath
|
||||
)
|
||||
|
||||
if ($Variables.Count -eq 0) {
|
||||
return $true
|
||||
}
|
||||
|
||||
$cmdInstructions = !$env:TF_BUILD -and $env:PS1UnderCmd -eq '1'
|
||||
$cmdInstructions = !$env:TF_BUILD -and !$env:GITHUB_ACTIONS -and $env:PS1UnderCmd -eq '1'
|
||||
if ($cmdInstructions) {
|
||||
Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe"
|
||||
Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue
|
||||
} else {
|
||||
Write-Host "Environment variables set:" -ForegroundColor Blue
|
||||
Write-Host ($Variables | Out-String)
|
||||
if ($PrependPath) {
|
||||
Write-Host "Paths prepended to PATH: $PrependPath"
|
||||
}
|
||||
}
|
||||
|
||||
if ($env:TF_BUILD) {
|
||||
Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path."
|
||||
}
|
||||
|
||||
if ($env:GITHUB_ACTIONS) {
|
||||
Write-Host "GitHub Actions detected. Logging commands will be used to propagate environment variables and prepend path."
|
||||
}
|
||||
|
||||
$Variables.GetEnumerator() |% {
|
||||
Set-Item -Path env:$($_.Key) -Value $_.Value
|
||||
|
||||
# If we're running in Azure Pipelines, set these environment variables
|
||||
# If we're running in a cloud CI, set these environment variables so they propagate.
|
||||
if ($env:TF_BUILD) {
|
||||
Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)"
|
||||
}
|
||||
if ($env:GITHUB_ACTIONS) {
|
||||
Write-Host "::set-env name=$($_.Key)::$($_.Value)"
|
||||
}
|
||||
|
||||
if ($cmdInstructions) {
|
||||
Write-Host "SET $($_.Key)=$($_.Value)"
|
||||
}
|
||||
}
|
||||
|
||||
$pathDelimiter = ';'
|
||||
if ($IsMacOS -or $IsLinux) {
|
||||
$pathDelimiter = ':'
|
||||
}
|
||||
|
||||
if ($PrependPath) {
|
||||
$PrependPath |% {
|
||||
$newPathValue = "$_$pathDelimiter$env:PATH"
|
||||
Set-Item -Path env:PATH -Value $newPathValue
|
||||
if ($cmdInstructions) {
|
||||
Write-Host "SET PATH=$newPathValue"
|
||||
}
|
||||
|
||||
if ($env:TF_BUILD) {
|
||||
Write-Host "##vso[task.prependpath]$_"
|
||||
}
|
||||
if ($env:GITHUB_ACTIONS) {
|
||||
Write-Host "::add-path::$_"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !$cmdInstructions
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<RunSettings>
|
||||
<DataCollectionRunSettings>
|
||||
<DataCollectors>
|
||||
<DataCollector friendlyName="blame" enabled="True">
|
||||
<Configuration>
|
||||
<CollectDump DumpType="full" />
|
||||
<CollectDumpOnTestSessionHang TestTimeout="30000" DumpType="full" />
|
||||
<!-- This ResultsDirectory must exist, but it is totally ignored. -->
|
||||
<ResultsDirectory>%BUILD_ARTIFACTSTAGINGDIRECTORY%</ResultsDirectory>
|
||||
</Configuration>
|
||||
</DataCollector>
|
||||
</DataCollectors>
|
||||
</DataCollectionRunSettings>
|
||||
</RunSettings>
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env pwsh
|
||||
|
||||
# This script returns all the artifacts that should be collected after a build.
|
||||
#
|
||||
# Each powershell artifact is expressed as an object with these properties:
|
||||
|
@ -28,7 +30,7 @@ Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% {
|
|||
Write-Warning "No files found for the `"$ArtifactName`" artifact."
|
||||
} else {
|
||||
$fileGroups.GetEnumerator() | % {
|
||||
$BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key), [UriKind]::Absolute)
|
||||
$BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key.ToString()), [UriKind]::Absolute)
|
||||
$_.Value | % {
|
||||
if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) {
|
||||
$_ = $_.FullName
|
||||
|
|
|
@ -5,51 +5,6 @@ param (
|
|||
[string]$ArtifactNameSuffix
|
||||
)
|
||||
|
||||
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
|
||||
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
|
||||
$ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
|
||||
} else {
|
||||
$ArtifactStagingFolder = "$RepoRoot\obj\_artifacts"
|
||||
if (Test-Path $ArtifactStagingFolder) {
|
||||
Remove-Item $ArtifactStagingFolder -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
function Create-SymbolicLink {
|
||||
param (
|
||||
$Link,
|
||||
$Target
|
||||
)
|
||||
|
||||
if ($Link -eq $Target) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Test-Path $Link) { Remove-Item $Link }
|
||||
$LinkContainer = Split-Path $Link -Parent
|
||||
if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer }
|
||||
Write-Verbose "Linking $Link to $Target"
|
||||
if ($IsMacOS -or $IsLinux) {
|
||||
ln $Target $Link
|
||||
} else {
|
||||
cmd /c mklink $Link $Target
|
||||
}
|
||||
}
|
||||
|
||||
# Stage all artifacts
|
||||
$Artifacts = & "$PSScriptRoot\_all.ps1"
|
||||
$Artifacts |% {
|
||||
$DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\')
|
||||
$Name = "$(Split-Path $_.Source -Leaf)"
|
||||
|
||||
#Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow
|
||||
|
||||
if (-not (Test-Path $DestinationFolder)) { New-Item -ItemType Directory -Path $DestinationFolder | Out-Null }
|
||||
if (Test-Path -PathType Leaf $_.Source) { # skip folders
|
||||
Create-SymbolicLink -Link "$DestinationFolder\$Name" -Target $_.Source
|
||||
}
|
||||
}
|
||||
|
||||
$Artifacts |% { $_.ArtifactName } | Get-Unique |% {
|
||||
Write-Host "##vso[artifact.upload containerfolder=$_$ArtifactNameSuffix;artifactname=$_$ArtifactNameSuffix;]$ArtifactStagingFolder/$_$ArtifactNameSuffix"
|
||||
& "$PSScriptRoot/_stage_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix |% {
|
||||
Write-Host "##vso[artifact.upload containerfolder=$($_.Name);artifactname=$($_.Name);]$($_.Path)"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
# This script links all the artifacts described by _all.ps1
|
||||
# into a staging directory, reading for uploading to a cloud build artifact store.
|
||||
# It returns a sequence of objects with Name and Path properties.
|
||||
|
||||
param (
|
||||
[string]$ArtifactNameSuffix
|
||||
)
|
||||
|
||||
$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..)))
|
||||
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
|
||||
$ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
|
||||
} else {
|
||||
$ArtifactStagingFolder = Join-Path $RepoRoot (Join-Path obj _artifacts)
|
||||
if (Test-Path $ArtifactStagingFolder) {
|
||||
Remove-Item $ArtifactStagingFolder -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
function Create-SymbolicLink {
|
||||
param (
|
||||
$Link,
|
||||
$Target
|
||||
)
|
||||
|
||||
if ($Link -eq $Target) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Test-Path $Link) { Remove-Item $Link }
|
||||
$LinkContainer = Split-Path $Link -Parent
|
||||
if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer }
|
||||
Write-Verbose "Linking $Link to $Target"
|
||||
if ($IsMacOS -or $IsLinux) {
|
||||
ln $Target $Link | Out-Null
|
||||
} else {
|
||||
cmd /c "mklink `"$Link`" `"$Target`"" | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
# Stage all artifacts
|
||||
$Artifacts = & "$PSScriptRoot\_all.ps1"
|
||||
$Artifacts |% {
|
||||
$DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\')
|
||||
$Name = "$(Split-Path $_.Source -Leaf)"
|
||||
|
||||
#Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow
|
||||
|
||||
if (-not (Test-Path $DestinationFolder)) { New-Item -ItemType Directory -Path $DestinationFolder | Out-Null }
|
||||
if (Test-Path -PathType Leaf $_.Source) { # skip folders
|
||||
Create-SymbolicLink -Link (Join-Path $DestinationFolder $Name) -Target $_.Source
|
||||
}
|
||||
}
|
||||
|
||||
$Artifacts |% { "$($_.ArtifactName)$ArtifactNameSuffix" } | Get-Unique |% {
|
||||
$artifact = New-Object -TypeName PSObject
|
||||
Add-Member -InputObject $artifact -MemberType NoteProperty -Name Name -Value $_
|
||||
Add-Member -InputObject $artifact -MemberType NoteProperty -Name Path -Value (Join-Path $ArtifactStagingFolder $_)
|
||||
Write-Output $artifact
|
||||
}
|
|
@ -14,7 +14,7 @@ steps:
|
|||
inputs:
|
||||
command: test
|
||||
projects: tests/**/*.Tests.csproj
|
||||
arguments: --configuration $(BuildConfiguration) --no-build -v n
|
||||
arguments: --configuration $(BuildConfiguration) --no-build -v n --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
|
||||
testRunTitle: $(Agent.JobName)
|
||||
|
||||
- script: |
|
||||
|
|
|
@ -10,7 +10,7 @@ steps:
|
|||
inputs:
|
||||
command: test
|
||||
projects: tests/MessagePack.Tests/MessagePack.Tests.csproj
|
||||
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 -v n
|
||||
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 -v n --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
|
||||
testRunTitle: netcoreapp2.1-$(Agent.JobName)
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
|
@ -18,5 +18,5 @@ steps:
|
|||
inputs:
|
||||
command: test
|
||||
projects: tests/MessagePackAnalyzer.Tests/MessagePackAnalyzer.Tests.csproj
|
||||
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 -v n
|
||||
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 -v n --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
|
||||
testRunTitle: netcoreapp3.1-$(Agent.JobName)-Analyzers
|
||||
|
|
|
@ -4,12 +4,11 @@ parameters:
|
|||
steps:
|
||||
|
||||
- powershell: |
|
||||
.\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }}
|
||||
$AccessToken = '$(System.AccessToken)' # Avoid specifying the access token directly on the init.ps1 command line to avoid it showing up in errors
|
||||
.\init.ps1 -AccessToken $AccessToken ${{ parameters['initArgs'] }} -UpgradePrerequisites
|
||||
dotnet --info
|
||||
displayName: Install prerequisites
|
||||
|
||||
- task: PowerShell@2
|
||||
inputs:
|
||||
filePath: azure-pipelines/variables/_pipelines.ps1
|
||||
failOnStderr: true
|
||||
- powershell: azure-pipelines/variables/_pipelines.ps1
|
||||
failOnStderr: true
|
||||
displayName: Set pipeline variables based on source
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env pwsh
|
||||
|
||||
# This script returns a hashtable of build variables that should be set
|
||||
# at the start of a build or release definition's execution.
|
||||
|
||||
|
|
|
@ -5,11 +5,17 @@
|
|||
# what the build would do. So only set them if they have not already been set.
|
||||
|
||||
(& "$PSScriptRoot\_all.ps1").GetEnumerator() |% {
|
||||
if (Test-Path -Path "env:$($_.Key.ToUpper())") {
|
||||
Write-Host "Skipping setting $($_.Key) because variable is already set." -ForegroundColor Cyan
|
||||
# Always use ALL CAPS for env var names since Azure Pipelines converts variable names to all caps and on non-Windows OS, env vars are case sensitive.
|
||||
$keyCaps = $_.Key.ToUpper()
|
||||
if (Test-Path -Path "env:$keyCaps") {
|
||||
Write-Host "Skipping setting $keyCaps because variable is already set." -ForegroundColor Cyan
|
||||
} else {
|
||||
Write-Host "$($_.Key)=$($_.Value)" -ForegroundColor Yellow
|
||||
Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)"
|
||||
Set-Item -Path "env:$($_.Key)" -Value $_.Value
|
||||
Write-Host "$keyCaps=$($_.Value)" -ForegroundColor Yellow
|
||||
if ($env:TF_BUILD) {
|
||||
Write-Host "##vso[task.setvariable variable=$keyCaps;]$($_.Value)"
|
||||
} elseif ($env:GITHUB_ACTIONS) {
|
||||
Write-Host "::set-env name=$keyCaps::$($_.Value)"
|
||||
}
|
||||
Set-Item -Path "env:$keyCaps" -Value $_.Value
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "3.1.300"
|
||||
"version": "3.1.301",
|
||||
"rollForward": "patch",
|
||||
"allowPrerelease": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#!/usr/bin/env pwsh
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Installs dependencies required to build and test the projects in this repository.
|
||||
.DESCRIPTION
|
||||
This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location,
|
||||
unless `-InstallLocality machine` is specified.
|
||||
This MAY not require elevation, as the SDK and runtimes are installed to a per-user location,
|
||||
unless the `-InstallLocality` switch is specified directing to a per-repo or per-machine location.
|
||||
See detailed help on that switch for more information.
|
||||
.PARAMETER InstallLocality
|
||||
A value indicating whether dependencies should be installed locally to the repo or at a per-user location.
|
||||
Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache.
|
||||
|
@ -14,6 +17,9 @@ Per-repo can lead to file locking issues when dotnet.exe is left running as a bu
|
|||
Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it.
|
||||
.PARAMETER NoPrerequisites
|
||||
Skips the installation of prerequisite software (e.g. SDKs, tools).
|
||||
.PARAMETER UpgradePrerequisites
|
||||
Takes time to install prerequisites even if they are already present in case they need to be upgraded.
|
||||
No effect if -NoPrerequisites is specified.
|
||||
.PARAMETER NoRestore
|
||||
Skips the package restore step.
|
||||
.PARAMETER AccessToken
|
||||
|
@ -26,14 +32,27 @@ Param (
|
|||
[Parameter()]
|
||||
[switch]$NoPrerequisites,
|
||||
[Parameter()]
|
||||
[switch]$UpgradePrerequisites,
|
||||
[Parameter()]
|
||||
[switch]$NoRestore,
|
||||
[Parameter()]
|
||||
[string]$AccessToken
|
||||
)
|
||||
|
||||
$EnvVars = @{}
|
||||
|
||||
if (!$NoPrerequisites) {
|
||||
& "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken
|
||||
& "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites
|
||||
& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality
|
||||
if ($LASTEXITCODE -eq 3010) {
|
||||
Exit 3010
|
||||
}
|
||||
|
||||
# The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests.
|
||||
# But it only works on Windows.
|
||||
if ($env:OS -eq 'Windows_NT') {
|
||||
$EnvVars['PROCDUMP_PATH'] = & "$PSScriptRoot\azure-pipelines\Get-ProcDump.ps1"
|
||||
}
|
||||
}
|
||||
|
||||
# Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines
|
||||
|
@ -51,6 +70,8 @@ try {
|
|||
throw "Failure while restoring packages."
|
||||
}
|
||||
}
|
||||
|
||||
& "$PSScriptRoot\azure-pipelines\Set-EnvVars.ps1" -Variables $EnvVars | Out-Null
|
||||
}
|
||||
catch {
|
||||
Write-Error $error[0]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env pwsh
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Installs the .NET SDK specified in the global.json file at the root of this repository,
|
||||
|
@ -21,7 +23,7 @@ Param (
|
|||
)
|
||||
|
||||
$DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools"
|
||||
if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot | Out-Null }
|
||||
if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot -WhatIf:$false | Out-Null }
|
||||
$DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot
|
||||
|
||||
# Look up actual required .NET Core SDK version from global.json
|
||||
|
@ -29,7 +31,7 @@ $sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1
|
|||
|
||||
# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them.
|
||||
$runtimeVersions = @()
|
||||
Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\sandbox\*.*proj" -Recurse |% {
|
||||
Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\tests\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% {
|
||||
$projXml = [xml](Get-Content -Path $_)
|
||||
$targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework
|
||||
if (!$targetFrameworks) {
|
||||
|
@ -75,31 +77,14 @@ Function Install-DotNet($Version, [switch]$Runtime) {
|
|||
Write-Host "Downloading .NET Core $sdkSubstring$Version..."
|
||||
$Installer = Get-InstallerExe -Version $Version -Runtime:$Runtime
|
||||
Write-Host "Installing .NET Core $sdkSubstring$Version..."
|
||||
cmd /c start /wait $Installer /install /quiet
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
cmd /c start /wait $Installer /install /passive /norestart
|
||||
if ($LASTEXITCODE -eq 3010) {
|
||||
Write-Verbose "Restart required"
|
||||
} elseif ($LASTEXITCODE -ne 0) {
|
||||
throw "Failure to install .NET Core SDK"
|
||||
}
|
||||
}
|
||||
|
||||
if ($InstallLocality -eq 'machine') {
|
||||
if ($IsMacOS -or $IsLinux) {
|
||||
Write-Error "Installing the .NET Core SDK or runtime at a machine-wide location is only supported by this script on Windows."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) {
|
||||
Install-DotNet -Version $sdkVersion
|
||||
}
|
||||
|
||||
$runtimeVersions |% {
|
||||
if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) {
|
||||
Install-DotNet -Version $_ -Runtime
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
$switches = @(
|
||||
'-Architecture','x64'
|
||||
)
|
||||
|
@ -108,7 +93,31 @@ $envVars = @{
|
|||
'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' = 'true';
|
||||
}
|
||||
|
||||
if ($InstallLocality -eq 'repo') {
|
||||
if ($InstallLocality -eq 'machine') {
|
||||
if ($IsMacOS -or $IsLinux) {
|
||||
$DotNetInstallDir = '/usr/share/dotnet'
|
||||
} else {
|
||||
$restartRequired = $false
|
||||
if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) {
|
||||
Install-DotNet -Version $sdkVersion
|
||||
$restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010)
|
||||
}
|
||||
|
||||
$runtimeVersions | Get-Unique |% {
|
||||
if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) {
|
||||
Install-DotNet -Version $_ -Runtime
|
||||
$restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010)
|
||||
}
|
||||
}
|
||||
|
||||
if ($restartRequired) {
|
||||
Write-Host -ForegroundColor Yellow "System restart required"
|
||||
Exit 3010
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
} elseif ($InstallLocality -eq 'repo') {
|
||||
$DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet"
|
||||
} elseif ($env:AGENT_TOOLSDIRECTORY) {
|
||||
$DotNetInstallDir = "$env:AGENT_TOOLSDIRECTORY/dotnet"
|
||||
|
@ -156,41 +165,5 @@ $runtimeVersions | Get-Unique |% {
|
|||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) {
|
||||
if ($env:TF_BUILD) {
|
||||
Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path."
|
||||
}
|
||||
|
||||
if ($IsMacOS -or $IsLinux) {
|
||||
$envVars['PATH'] = "${DotNetInstallDir}:$env:PATH"
|
||||
} else {
|
||||
$envVars['PATH'] = "$DotNetInstallDir;$env:PATH"
|
||||
}
|
||||
|
||||
$envVars.GetEnumerator() |% {
|
||||
Set-Item -Path env:$($_.Key) -Value $_.Value
|
||||
|
||||
# If we're running in Azure Pipelines, set these environment variables
|
||||
if ($env:TF_BUILD) {
|
||||
Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)"
|
||||
}
|
||||
}
|
||||
|
||||
if ($env:TF_BUILD) {
|
||||
Write-Host "##vso[task.prependpath]$DotNetInstallDir"
|
||||
}
|
||||
}
|
||||
|
||||
if ($env:PS1UnderCmd -eq '1') {
|
||||
Write-Warning "Environment variable changes will be lost because you're running under cmd.exe. Run these commands manually:"
|
||||
$envVars.GetEnumerator() |% {
|
||||
if ($_.Key -eq 'PATH') {
|
||||
# Special case this one for readability
|
||||
Write-Host "SET PATH=$DotNetInstallDir;%PATH%"
|
||||
} else {
|
||||
Write-Host "SET $($_.Key)=$($_.Value)"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Write-Host "Environment variables set:" -ForegroundColor Blue
|
||||
$envVars
|
||||
& "$PSScriptRoot/../azure-pipelines/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null
|
||||
}
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
#!/usr/bin/env pwsh
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Downloads and installs the Microsoft Artifacts Credential Provider
|
||||
from https://github.com/microsoft/artifacts-credprovider
|
||||
to assist in authenticating to Azure Artifact feeds in interactive development
|
||||
or unattended build agents.
|
||||
.PARAMETER Force
|
||||
Forces install of the CredProvider plugin even if one already exists. This is useful to upgrade an older version.
|
||||
.PARAMETER AccessToken
|
||||
An optional access token for authenticating to Azure Artifacts authenticated feeds.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter()]
|
||||
[switch]$Force,
|
||||
[Parameter()]
|
||||
[string]$AccessToken
|
||||
)
|
||||
|
@ -35,19 +41,25 @@ if ($IsMacOS -or $IsLinux) {
|
|||
chmod u+x $installerScript
|
||||
}
|
||||
|
||||
& $installerScript
|
||||
& $installerScript -Force:$Force
|
||||
|
||||
if ($AccessToken) {
|
||||
$endpoints = @()
|
||||
|
||||
$nugetConfig = [xml](Get-Content -Path "$PSScriptRoot\..\nuget.config")
|
||||
$endpointURIs = @()
|
||||
Get-ChildItem "$PSScriptRoot\..\nuget.config" -Recurse |% {
|
||||
$nugetConfig = [xml](Get-Content -Path $_)
|
||||
|
||||
$nugetConfig.configuration.packageSources.add |? { ($_.value -match '^https://pkgs\.dev\.azure\.com/') -or ($_.value -match '^https://[\w\-]+\.pkgs\.visualstudio\.com/') } |% {
|
||||
$endpoint = New-Object -TypeName PSObject
|
||||
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name endpoint -Value $_.value
|
||||
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name username -Value ado
|
||||
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name password -Value $AccessToken
|
||||
$endpoints += $endpoint
|
||||
$nugetConfig.configuration.packageSources.add |? { ($_.value -match '^https://pkgs\.dev\.azure\.com/') -or ($_.value -match '^https://[\w\-]+\.pkgs\.visualstudio\.com/') } |% {
|
||||
if ($endpointURIs -notcontains $_.Value) {
|
||||
$endpointURIs += $_.Value
|
||||
$endpoint = New-Object -TypeName PSObject
|
||||
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name endpoint -Value $_.value
|
||||
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name username -Value ado
|
||||
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name password -Value $AccessToken
|
||||
$endpoints += $endpoint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$auth = New-Object -TypeName PSObject
|
||||
|
|
Загрузка…
Ссылка в новой задаче