From fc80bb085a39753fafe677d9d9143c0dffab0a21 Mon Sep 17 00:00:00 2001 From: Kirill Osenkov Date: Thu, 27 Jun 2019 15:10:52 -0700 Subject: [PATCH 1/2] Avoid a first-chance FileNotFoundException when a ruleset include is not found. (#34696) When a .ruleset file includes a non-existing ruleset reference we receive null from ResolveIncludePath and throw a FileNotFoundException, which is the immediately caught in LoadRuleSet. We can avoid the first-chance exception and the associated allocations if we just return null. A missing ruleset is not an exceptional situation so no need to use exceptions for control flow here if we can avoid it. --- src/Compilers/Core/Portable/RuleSet/RuleSetInclude.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Compilers/Core/Portable/RuleSet/RuleSetInclude.cs b/src/Compilers/Core/Portable/RuleSet/RuleSetInclude.cs index f1663fb71300a..c93e36906b296 100644 --- a/src/Compilers/Core/Portable/RuleSet/RuleSetInclude.cs +++ b/src/Compilers/Core/Portable/RuleSet/RuleSetInclude.cs @@ -55,6 +55,11 @@ public RuleSet LoadRuleSet(RuleSet parent) try { path = GetIncludePath(parent); + if (path == null) + { + return null; + } + ruleSet = RuleSetProcessor.LoadFromFile(path); } catch (FileNotFoundException) @@ -78,11 +83,9 @@ public RuleSet LoadRuleSet(RuleSet parent) private string GetIncludePath(RuleSet parent) { var resolvedIncludePath = ResolveIncludePath(_includePath, parent?.FilePath); - - // If we still couldn't find it then throw an exception; if (resolvedIncludePath == null) { - throw new FileNotFoundException(string.Format(CodeAnalysisResources.FailedToResolveRuleSetName, _includePath), _includePath); + return null; } // Return the canonical full path From ea4ab12b29aae25a5188af9e0ae0350f74a17f26 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Thu, 27 Jun 2019 16:15:55 -0700 Subject: [PATCH 2/2] Update dependencies from https://github.com/dotnet/arcade build 20190626.44 (#36815) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19326.44 --- eng/Version.Details.xml | 4 +- eng/Versions.props | 5 +- eng/common/post-build/promote-build.ps1 | 53 +++++++++++++++ eng/common/sdl/extract-artifact-packages.ps1 | 66 +++++++++++++++++++ eng/common/templates/job/execute-sdl.yml | 10 +++ .../channels/public-dev-release.yml | 4 ++ .../channels/public-validation-release.yml | 4 ++ .../templates/post-build/promote-build.yml | 11 ++-- global.json | 4 +- 9 files changed, 146 insertions(+), 15 deletions(-) create mode 100644 eng/common/post-build/promote-build.ps1 create mode 100644 eng/common/sdl/extract-artifact-packages.ps1 diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 1902afec14160..17191ef43d6e4 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 4b3d46cc75969c4e2de5786ec2b10a430b26dd9f + d39a62deaf3aa4e03c0b7dadc320a517e0e00187 diff --git a/eng/Versions.props b/eng/Versions.props index 9c3641a5606d6..4456b21c6d5be 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,4 +1,4 @@ - + $(MajorVersion).$(MinorVersion).0.0 - 2.9.3 @@ -27,7 +25,6 @@ 3.1.0-beta1-19113-04 16.1.101 - diff --git a/eng/common/post-build/promote-build.ps1 b/eng/common/post-build/promote-build.ps1 new file mode 100644 index 0000000000000..84a608fa56923 --- /dev/null +++ b/eng/common/post-build/promote-build.ps1 @@ -0,0 +1,53 @@ +param( + [Parameter(Mandatory=$true)][int] $BuildId, + [Parameter(Mandatory=$true)][int] $ChannelId, + [Parameter(Mandatory=$true)][string] $BarToken, + [string] $MaestroEndpoint = "https://maestro-prod.westus2.cloudapp.azure.com", + [string] $ApiVersion = "2019-01-16" +) + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 2.0 + +. $PSScriptRoot\..\tools.ps1 + +function Get-Headers([string]$accept, [string]$barToken) { + $headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]' + $headers.Add('Accept',$accept) + $headers.Add('Authorization',"Bearer $barToken") + return $headers +} + +try { + $maestroHeaders = Get-Headers 'application/json' $BarToken + + # Get info about which channels the build has already been promoted to + $getBuildApiEndpoint = "$MaestroEndpoint/api/builds/${BuildId}?api-version=$ApiVersion" + $buildInfo = Invoke-WebRequest -Method Get -Uri $getBuildApiEndpoint -Headers $maestroHeaders | ConvertFrom-Json + + if (!$buildInfo) { + Write-Host "Build with BAR ID $BuildId was not found in BAR!" + ExitWithExitCode 1 + } + + # Find whether the build is already assigned to the channel or not + if ($buildInfo.channels) { + foreach ($channel in $buildInfo.channels) { + if ($channel.Id -eq $ChannelId) { + Write-Host "The build with BAR ID $BuildId is already on channel $ChannelId!" + ExitWithExitCode 0 + } + } + } + + Write-Host "Build not present in channel $ChannelId. Promoting build ... " + + $promoteBuildApiEndpoint = "$maestroEndpoint/api/channels/${ChannelId}/builds/${BuildId}?api-version=$ApiVersion" + Invoke-WebRequest -Method Post -Uri $promoteBuildApiEndpoint -Headers $maestroHeaders + Write-Host "done." +} +catch { + Write-Host "There was an error while trying to promote build '$BuildId' to channel '$ChannelId'" + Write-Host $_ + Write-Host $_.ScriptStackTrace +} diff --git a/eng/common/sdl/extract-artifact-packages.ps1 b/eng/common/sdl/extract-artifact-packages.ps1 new file mode 100644 index 0000000000000..0f6a6e49b92aa --- /dev/null +++ b/eng/common/sdl/extract-artifact-packages.ps1 @@ -0,0 +1,66 @@ +param( + [Parameter(Mandatory=$true)][string] $InputPath, # Full path to directory where artifact packages are stored + [Parameter(Mandatory=$true)][string] $ExtractPath # Full path to directory where the packages will be extracted +) + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 2.0 +$ExtractPackage = { + param( + [string] $PackagePath # Full path to a NuGet package + ) + + if (!(Test-Path $PackagePath)) { + Write-PipelineTaskError "Input file does not exist: $PackagePath" + ExitWithExitCode 1 + } + + $RelevantExtensions = @(".dll", ".exe", ".pdb") + Write-Host -NoNewLine "Extracting" ([System.IO.Path]::GetFileName($PackagePath)) "... " + + $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) + $ExtractPath = Join-Path -Path $using:ExtractPath -ChildPath $PackageId + + Add-Type -AssemblyName System.IO.Compression.FileSystem + + [System.IO.Directory]::CreateDirectory($ExtractPath); + + try { + $zip = [System.IO.Compression.ZipFile]::OpenRead($PackagePath) + + $zip.Entries | + Where-Object {$RelevantExtensions -contains [System.IO.Path]::GetExtension($_.Name)} | + ForEach-Object { + $TargetFile = Join-Path -Path $ExtractPath -ChildPath $_.Name + + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $TargetFile, $true) + } + } + catch { + + } + finally { + $zip.Dispose() + } + } + function ExtractArtifacts { + $Jobs = @() + Get-ChildItem "$InputPath\*.nupkg" | + ForEach-Object { + $Jobs += Start-Job -ScriptBlock $ExtractPackage -ArgumentList $_.FullName + } + + foreach ($Job in $Jobs) { + Wait-Job -Id $Job.Id | Receive-Job + } +} + +try { + Measure-Command { ExtractArtifacts } +} +catch { + Write-Host $_ + Write-Host $_.Exception + Write-Host $_.ScriptStackTrace + ExitWithExitCode 1 +} diff --git a/eng/common/templates/job/execute-sdl.yml b/eng/common/templates/job/execute-sdl.yml index 39a8e808387ec..5837f3d56d3a3 100644 --- a/eng/common/templates/job/execute-sdl.yml +++ b/eng/common/templates/job/execute-sdl.yml @@ -20,6 +20,16 @@ jobs: downloadType: specific files matchingPattern: "**" downloadPath: $(Build.SourcesDirectory)\artifacts + - powershell: eng/common/sdl/extract-artifact-packages.ps1 + -InputPath $(Build.SourcesDirectory)\artifacts\BlobArtifacts + -ExtractPath $(Build.SourcesDirectory)\artifacts\BlobArtifacts + displayName: Extract Blob Artifacts + continueOnError: ${{ parameters.continueOnError }} + - powershell: eng/common/sdl/extract-artifact-packages.ps1 + -InputPath $(Build.SourcesDirectory)\artifacts\PackageArtifacts + -ExtractPath $(Build.SourcesDirectory)\artifacts\PackageArtifacts + displayName: Extract Package Artifacts + continueOnError: ${{ parameters.continueOnError }} - task: NuGetToolInstaller@1 displayName: 'Install NuGet.exe' - task: NuGetCommand@2 diff --git a/eng/common/templates/post-build/channels/public-dev-release.yml b/eng/common/templates/post-build/channels/public-dev-release.yml index dfbc246826bd8..79c6822db7203 100644 --- a/eng/common/templates/post-build/channels/public-dev-release.yml +++ b/eng/common/templates/post-build/channels/public-dev-release.yml @@ -160,3 +160,7 @@ stages: targetType: inline script: | darc gather-drop --non-shipping --continue-on-error --id $(BARBuildId) --output-dir $(Agent.BuildDirectory)/Temp/Drop/ --bar-uri https://maestro-prod.westus2.cloudapp.azure.com/ --password $(MaestroAccessToken) --latest-location + + - template: ../promote-build.yml + parameters: + ChannelId: ${{ variables.PublicDevRelease_30_Channel_Id }} diff --git a/eng/common/templates/post-build/channels/public-validation-release.yml b/eng/common/templates/post-build/channels/public-validation-release.yml index 0ef68c2b01b37..114477d3adb9c 100644 --- a/eng/common/templates/post-build/channels/public-validation-release.yml +++ b/eng/common/templates/post-build/channels/public-validation-release.yml @@ -113,3 +113,7 @@ stages: targetType: inline script: | darc gather-drop --non-shipping --continue-on-error --id $(BARBuildId) --output-dir $(Agent.BuildDirectory)/Temp/Drop/ --bar-uri https://maestro-prod.westus2.cloudapp.azure.com --password $(MaestroAccessToken) --latest-location + + - template: ../promote-build.yml + parameters: + ChannelId: ${{ variables.PublicValidationRelease_30_Channel_Id }} diff --git a/eng/common/templates/post-build/promote-build.yml b/eng/common/templates/post-build/promote-build.yml index 57241bab88fce..af48b0b339e28 100644 --- a/eng/common/templates/post-build/promote-build.yml +++ b/eng/common/templates/post-build/promote-build.yml @@ -18,10 +18,7 @@ jobs: - task: PowerShell@2 displayName: Add Build to Channel inputs: - targetType: inline - script: | - $headers = @{ - "Accept" = "application/json" - "Authorization" = "Bearer $(MaestroAccessToken)" - } - Invoke-RestMethod -Method Post -Headers $headers -Uri https://maestro-prod.westus2.cloudapp.azure.com/api/channels/$(ChannelId)/builds/$(BARBuildId)?api-version=2019-01-16 + filePath: $(Build.SourcesDirectory)/eng/common/post-build/promote-build.ps1 + arguments: -BuildId $(BARBuildId) + -ChannelId $(ChannelId) + -BarToken $(MaestroAccessToken) diff --git a/global.json b/global.json index 241dbbc45d652..74e69879b6b62 100644 --- a/global.json +++ b/global.json @@ -1,12 +1,12 @@ { "tools": { - "dotnet": "3.0.100-preview6-012105", + "dotnet": "3.0.100-preview6-012264", "vs": { "version": "16.0" }, "xcopy-msbuild": "16.0.0-alpha" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19326.2" + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19326.44" } }