diff --git a/eng/ApiCompatibility/README.md b/eng/ApiCompatibility/README.md new file mode 100644 index 00000000000..fb99d290011 --- /dev/null +++ b/eng/ApiCompatibility/README.md @@ -0,0 +1,12 @@ +### Mark Shipped Tool +======== + +This tool should be run after every supported release that has API changes. It will +merge the collection of PublicApi.Shipped.txt files with the PublicApi.Unshipped.txt +versions. This will take into account `*REMOVED*` elements when updating the files. + +Usage: + +``` cmd +mark-shipped.cmd +``` \ No newline at end of file diff --git a/eng/ApiCompatibility/mark-shipped.cmd b/eng/ApiCompatibility/mark-shipped.cmd new file mode 100644 index 00000000000..73987578815 --- /dev/null +++ b/eng/ApiCompatibility/mark-shipped.cmd @@ -0,0 +1,2 @@ +@echo off +powershell -noprofile -executionPolicy RemoteSigned -file "%~dp0\mark-shipped.ps1" diff --git a/eng/ApiCompatibility/mark-shipped.ps1 b/eng/ApiCompatibility/mark-shipped.ps1 new file mode 100644 index 00000000000..84f03e54e7a --- /dev/null +++ b/eng/ApiCompatibility/mark-shipped.ps1 @@ -0,0 +1,51 @@ +[CmdletBinding(PositionalBinding=$false)] +param () + +Set-StrictMode -version 2.0 +$ErrorActionPreference = "Stop" + +function MarkShipped([string]$dir) { + $shippedFilePath = Join-Path $dir "PublicAPI.Shipped.txt" + $shipped = Get-Content $shippedFilePath + if ($null -eq $shipped) { + $shipped = @() + } + + $unshippedFilePath = Join-Path $dir "PublicAPI.Unshipped.txt" + $unshipped = Get-Content $unshippedFilePath + $removed = @() + $removedPrefix = "*REMOVED*"; + Write-Host "Processing $dir" + + foreach ($item in $unshipped) { + if ($item.Length -gt 0) { + if ($item.StartsWith($removedPrefix)) { + $item = $item.Substring($removedPrefix.Length) + $removed += $item + } + else { + $shipped += $item + } + } + } + + $shipped | Sort-Object | ?{ -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii + $null | Out-File $unshippedFilePath -Encoding Ascii +} + +try { + Push-Location $PSScriptRoot\..\.. + + foreach ($file in Get-ChildItem -re -in "PublicApi.Shipped.txt") { + $dir = Split-Path -parent $file + MarkShipped $dir + } +} +catch { + Write-Host $_ + Write-Host $_.Exception + exit 1 +} +finally { + Pop-Location +}