Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Update dependencies from dotnet/arcade #338

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19312.21">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19314.27">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>e5cd71926eaa13aba3138c14cd80def0ccfebb30</Sha>
<Sha>372249cafc24384ae3488aab4e815e54c2ff3938</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
2 changes: 1 addition & 1 deletion eng/common/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ try {
}
catch {
Write-Host $_.ScriptStackTrace
Write-PipelineTaskError -Message $_
Write-PipelineTelemetryError -Category "InitializeToolset" -Message $_
ExitWithExitCode 1
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Source for this file was taken from https://github.com/microsoft/azure-pipelines-task-lib/blob/11c9439d4af17e6475d9fe058e6b2e03914d17e6/powershell/VstsTaskSdk/LoggingCommandFunctions.ps1
# Source for this file was taken from https://github.com/microsoft/azure-pipelines-task-lib/blob/11c9439d4af17e6475d9fe058e6b2e03914d17e6/powershell/VstsTaskSdk/LoggingCommandFunctions.ps1 and modified.

# NOTE: You should not be calling these method directly as they are likely to change. Instead you should be calling the Write-Pipeline* functions defined in tools.ps1

Expand All @@ -12,6 +12,93 @@ $script:loggingCommandEscapeMappings = @( # TODO: WHAT ABOUT "="? WHAT ABOUT "%"
# TODO: BUG: Escape % ???
# TODO: Add test to verify don't need to escape "=".

function Write-PipelineTelemetryError {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Category,
[Parameter(Mandatory = $true)]
[string]$Message,
[Parameter(Mandatory = $false)]
[string]$Type = 'error',
[string]$ErrCode,
[string]$SourcePath,
[string]$LineNumber,
[string]$ColumnNumber,
[switch]$AsOutput)

$PSBoundParameters.Remove("Category") | Out-Null

$Message = "(NETCORE_ENGINEERING_TELEMETRY=$Category) $Message"
$PSBoundParameters.Remove("Message") | Out-Null
$PSBoundParameters.Add("Message", $Message)

Write-PipelineTaskError @PSBoundParameters
}

function Write-PipelineTaskError {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Message,
[Parameter(Mandatory = $false)]
[string]$Type = 'error',
[string]$ErrCode,
[string]$SourcePath,
[string]$LineNumber,
[string]$ColumnNumber,
[switch]$AsOutput)

if(!$ci) {
if($Type -eq 'error') {
Write-Host $Message -ForegroundColor Red
return
}
elseif ($Type -eq 'warning') {
Write-Host $Message -ForegroundColor Yellow
return
}
}

if(($Type -ne 'error') -and ($Type -ne 'warning')) {
Write-Host $Message
return
}
if(-not $PSBoundParameters.ContainsKey('Type')) {
$PSBoundParameters.Add('Type', 'error')
}
Write-LogIssue @PSBoundParameters
}

function Write-PipelineSetVariable {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Name,
[string]$Value,
[switch]$Secret,
[switch]$AsOutput)

if($ci) {
Write-LoggingCommand -Area 'task' -Event 'setvariable' -Data $Value -Properties @{
'variable' = $Name
'isSecret' = $Secret
'isOutput' = 'true'
} -AsOutput:$AsOutput
}
}

function Write-PipelinePrependPath {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$Path,
[switch]$AsOutput)
if($ci) {
Write-LoggingCommand -Area 'task' -Event 'prependpath' -Data $Path -AsOutput:$AsOutput
}
}

<########################################
# Private functions.
########################################>
Expand Down
102 changes: 102 additions & 0 deletions eng/common/pipeline-logging-functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env bash

function Write-PipelineTelemetryError {
local telemetry_category=''
local function_args=()
local message=''
while [[ $# -gt 0 ]]; do
opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
case "$opt" in
-category|-c)
telemetry_category=$2
shift
;;
-*)
function_args+=("$1 $2")
shift
;;
*)
message=$*
;;
esac
shift
done

if [[ "$ci" != true ]]; then
echo "$message" >&2
return
fi

message="(NETCORE_ENGINEERING_TELEMETRY=$telemetry_category) $message"
function_args+=("$message")

Write-PipelineTaskError $function_args
}

function Write-PipelineTaskError {
if [[ "$ci" != true ]]; then
echo "$@" >&2
return
fi

message_type="error"
sourcepath=''
linenumber=''
columnnumber=''
error_code=''

while [[ $# -gt 0 ]]; do
opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
case "$opt" in
-type|-t)
message_type=$2
shift
;;
-sourcepath|-s)
sourcepath=$2
shift
;;
-linenumber|-ln)
linenumber=$2
shift
;;
-columnnumber|-cn)
columnnumber=$2
shift
;;
-errcode|-e)
error_code=$2
shift
;;
*)
break
;;
esac

shift
done

message="##vso[task.logissue"

message="$message type=$message_type"

if [ -n "$sourcepath" ]; then
message="$message;sourcepath=$sourcepath"
fi

if [ -n "$linenumber" ]; then
message="$message;linenumber=$linenumber"
fi

if [ -n "$columnnumber" ]; then
message="$message;columnnumber=$columnnumber"
fi

if [ -n "$error_code" ]; then
message="$message;code=$error_code"
fi

message="$message]$*"
echo "$message"
}

87 changes: 13 additions & 74 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,69 +92,6 @@ function Exec-Process([string]$command, [string]$commandArgs) {
}
}

function Write-PipelineTaskError {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Message,
[Parameter(Mandatory = $false)]
[string]$Type = 'error',
[string]$ErrCode,
[string]$SourcePath,
[string]$LineNumber,
[string]$ColumnNumber,
[switch]$AsOutput)

if(!$ci) {
if($Type -eq 'error') {
Write-Host $Message -ForegroundColor Red
return
}
elseif ($Type -eq 'warning') {
Write-Host $Message -ForegroundColor Yellow
return
}
}

if(($Type -ne 'error') -and ($Type -ne 'warning')) {
Write-Host $Message
return
}
if(-not $PSBoundParameters.ContainsKey('Type')) {
$PSBoundParameters.Add('Type', 'error')
}
Write-LogIssue @PSBoundParameters
}

function Write-PipelineSetVariable {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Name,
[string]$Value,
[switch]$Secret,
[switch]$AsOutput)

if($ci) {
Write-LoggingCommand -Area 'task' -Event 'setvariable' -Data $Value -Properties @{
'variable' = $Name
'isSecret' = $Secret
'isOutput' = 'true'
} -AsOutput:$AsOutput
}
}

function Write-PipelinePrependPath {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$Path,
[switch]$AsOutput)
if($ci) {
Write-LoggingCommand -Area 'task' -Event 'prependpath' -Data $Path -AsOutput:$AsOutput
}
}

function InitializeDotNetCli([bool]$install) {
if (Test-Path variable:global:_DotNetInstallDir) {
return $global:_DotNetInstallDir
Expand Down Expand Up @@ -197,7 +134,7 @@ function InitializeDotNetCli([bool]$install) {
if ($install) {
InstallDotNetSdk $dotnetRoot $dotnetSdkVersion
} else {
Write-PipelineTaskError "Unable to find dotnet with SDK version '$dotnetSdkVersion'"
Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Unable to find dotnet with SDK version '$dotnetSdkVersion'"
ExitWithExitCode 1
}
}
Expand Down Expand Up @@ -245,7 +182,7 @@ function InstallDotNet([string] $dotnetRoot, [string] $version, [string] $archit

& $installScript @installParameters
if ($lastExitCode -ne 0) {
Write-PipelineTaskError -Message "Failed to install dotnet cli (exit code '$lastExitCode')."
Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Failed to install dotnet cli (exit code '$lastExitCode')."
ExitWithExitCode $lastExitCode
}
}
Expand Down Expand Up @@ -419,7 +356,7 @@ function InitializeBuildTool() {

if ($msbuildEngine -eq "dotnet") {
if (!$dotnetRoot) {
Write-PipelineTaskError "/global.json must specify 'tools.dotnet'."
Write-PipelineTelemetryError -Category "InitializeToolset" -Message "/global.json must specify 'tools.dotnet'."
ExitWithExitCode 1
}

Expand All @@ -428,13 +365,13 @@ function InitializeBuildTool() {
try {
$msbuildPath = InitializeVisualStudioMSBuild -install:$restore
} catch {
Write-PipelineTaskError $_
Write-PipelineTelemetryError -Category "InitializeToolset" -Message $_
ExitWithExitCode 1
}

$buildTool = @{ Path = $msbuildPath; Command = ""; Tool = "vs"; Framework = "net472" }
} else {
Write-PipelineTaskError "Unexpected value of -msbuildEngine: '$msbuildEngine'."
Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Unexpected value of -msbuildEngine: '$msbuildEngine'."
ExitWithExitCode 1
}

Expand All @@ -451,7 +388,7 @@ function GetDefaultMSBuildEngine() {
return "dotnet"
}

Write-PipelineTaskError "-msbuildEngine must be specified, or /global.json must specify 'tools.dotnet' or 'tools.vs'."
Write-PipelineTelemetryError -Category "InitializeToolset" -Message "-msbuildEngine must be specified, or /global.json must specify 'tools.dotnet' or 'tools.vs'."
ExitWithExitCode 1
}

Expand Down Expand Up @@ -504,7 +441,7 @@ function InitializeToolset() {
}

if (-not $restore) {
Write-PipelineTaskError "Toolset version $toolsetVersion has not been restored."
Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Toolset version $toolsetVersion has not been restored."
ExitWithExitCode 1
}

Expand Down Expand Up @@ -564,11 +501,13 @@ function MSBuild() {
function MSBuild-Core() {
if ($ci) {
if (!$binaryLog) {
throw "Binary log must be enabled in CI build."
Write-PipelineTaskError -Message "Binary log must be enabled in CI build."
ExitWithExitCode 1
}

if ($nodeReuse) {
throw "Node reuse must be disabled in CI build."
Write-PipelineTaskError -Message "Node reuse must be disabled in CI build."
ExitWithExitCode 1
}
}

Expand All @@ -589,7 +528,7 @@ function MSBuild-Core() {
$exitCode = Exec-Process $buildTool.Path $cmdArgs

if ($exitCode -ne 0) {
Write-PipelineTaskError "Build failed."
Write-PipelineTaskError -Message "Build failed."

$buildLog = GetMSBuildBinaryLogCommandLineArgument $args
if ($buildLog -ne $null) {
Expand Down Expand Up @@ -617,7 +556,7 @@ function GetMSBuildBinaryLogCommandLineArgument($arguments) {
return $null
}

. $PSScriptRoot\LoggingCommandFunctions.ps1
. $PSScriptRoot\pipeline-logging-functions.ps1

$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot "..\..")
$EngRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
Expand Down
Loading