Add init.cmd, nbgv tool improvements, etc.

This commit is contained in:
Andrew Arnott 2019-07-15 10:35:04 -06:00
Родитель 2da189df18
Коммит 00bcb28bfc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: A9B9910CDCCDA441
8 изменённых файлов: 74 добавлений и 18 удалений

Просмотреть файл

@ -0,0 +1,29 @@
<#
.SYNOPSIS
Gets the path to the nbgv CLI tool, installing it if necessary.
#>
Param(
)
$existingTool = Get-Command "nbgv" -ErrorAction SilentlyContinue
if ($existingTool) {
return $existingTool.Path
}
if ($env:AGENT_TEMPDIRECTORY) {
$toolInstallDir = "$env:AGENT_TEMPDIRECTORY/$env:BUILD_BUILDID"
} else {
$toolInstallDir = "$PSScriptRoot/obj/tools"
}
$toolPath = "$toolInstallDir/nbgv"
if (!(Test-Path $toolPath)) { New-Item -Path $toolPath -ItemType Directory | Out-Null }
$toolPath = (Resolve-Path $toolPath).Path
if (!(Get-Command $toolPath -ErrorAction SilentlyContinue)) {
Write-Host "Installing nbgv to $toolInstallDir"
dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot\nbgv.nuget.config" | Out-Null
}
# Normalize the path on the way out.
return (Get-Command $toolPath).Path

Просмотреть файл

@ -6,7 +6,6 @@ param (
)
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
if (!$env:BUILDCONFIGURATION) { throw "BUILDCONFIGURATION environment variable must be set." }
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
$ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
} else {

Просмотреть файл

@ -5,11 +5,11 @@ jobs:
- job: Windows
pool: ${{ parameters.windowsPool }}
steps:
- checkout: self
clean: true # "all" doesn't work, but "true" does, despite YAML docs
- template: install-dependencies.yml
- powershell: |
dotnet tool install --tool-path $(Agent.TempDirectory) nbgv --ignore-failed-sources
$(Agent.TempDirectory)/nbgv cloud
- powershell: '& (azure-pipelines\Get-nbgv.ps1) cloud'
displayName: Set build number
- template: dotnet.yml
@ -19,6 +19,8 @@ jobs:
pool:
vmImage: Ubuntu 16.04
steps:
- checkout: self
clean: true # "all" doesn't work, but "true" does, despite YAML docs
- template: install-dependencies.yml
- template: dotnet.yml
- template: expand-template.yml
@ -40,6 +42,8 @@ jobs:
vmImage: Ubuntu 16.04
condition: succeededOrFailed()
steps:
- checkout: self
clean: true # "all" doesn't work, but "true" does, despite YAML docs
- template: install-dependencies.yml
- template: publish-codecoverage.yml
- template: publish-deployables.yml

Просмотреть файл

@ -1,11 +1,12 @@
steps:
- task: PowerShell@2
inputs:
filePath: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true
displayName: Set pipeline variables based on source
- powershell: |
.\init.ps1
dotnet --info
displayName: Install prerequisites
- task: PowerShell@2
inputs:
filePath: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true
displayName: Set pipeline variables based on source

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -4,6 +4,7 @@
$vars = @{}
Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" |% {
Write-Host "Computing $($_.BaseName) variable"
$vars[$_.BaseName] = & $_
}

3
init.cmd Normal file
Просмотреть файл

@ -0,0 +1,3 @@
@set PS1UnderCmd=1
powershell.exe -ExecutionPolicy bypass -Command "& '%~dpn0.ps1'" %*
@set PS1UnderCmd=

Просмотреть файл

@ -93,14 +93,17 @@ $runtimeVersions | Get-Unique |% {
}
}
Write-Host "Environment variables to be set:" -ForegroundColor Blue
$envVars
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
@ -110,13 +113,22 @@ if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these
}
}
if ($IsMacOS -or $IsLinux) {
$env:PATH = "${DotNetInstallDir}:$env:PATH"
} else {
$env:PATH = "$DotNetInstallDir;$env:PATH"
}
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
}