Skip to content

Commit b9cd319

Browse files
committed
Add support for RelativePackagePath or ServiceDirectory
1 parent b90d168 commit b9cd319

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

eng/scripts/Export-API.ps1

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[CmdletBinding()]
22
param (
3-
[Parameter(Position=0, Mandatory=$true, ParameterSetName='ServiceDirectory')]
3+
[Parameter(Position=0)]
4+
5+
[Parameter(Mandatory=$true, ParameterSetName='ServiceDirectory')]
46
[string] $ServiceDirectory,
57

68
[string] $SDKType = "all",
@@ -16,9 +18,6 @@ if ($SpellCheckPublicApiSurface -and -not (Get-Command 'npx')) {
1618
Write-Error "Could not locate npx. Install NodeJS (includes npm and npx) https://nodejs.org/en/download/"
1719
exit 1
1820
}
19-
20-
. $PSScriptRoot/../common/scripts/Helpers/CommandInvocation-Helpers.ps1
21-
2221
$relativePackagePath = $ServiceDirectory
2322
$apiListingFilesFilter = "$PSScriptRoot/../../sdk/$ServiceDirectory/*/api/*.cs"
2423

@@ -33,11 +32,31 @@ $debugLogging = $env:SYSTEM_DEBUG -eq "true"
3332
$logsFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
3433
$diagnosticArguments = ($debugLogging -and $logsFolder) ? "/binarylogger:$logsFolder/exportapi.binlog" : ""
3534

36-
Invoke-LoggedMsbuildCommand "dotnet build /t:ExportApi /p:RunApiCompat=false /p:InheritDocEnabled=false /p:GeneratePackageOnBuild=false /p:Configuration=Release /p:IncludeSamples=false /p:IncludePerf=false /p:IncludeStress=false /p:IncludeTests=false /p:Scope=`"$relativePackagePath`" /p:SDKType=$SDKType /restore $servicesProj $diagnosticArguments"
35+
dotnet build `
36+
/t:ExportApi `
37+
/p:RunApiCompat=false `
38+
/p:InheritDocEnabled=false `
39+
/p:GeneratePackageOnBuild=false `
40+
/p:Configuration=Release `
41+
/p:IncludeSamples=false `
42+
/p:IncludePerf=false `
43+
/p:IncludeStress=false `
44+
/p:IncludeTests=false `
45+
/p:Scope="$relativePackagePath" `
46+
/p:SDKType=$SDKType `
47+
/restore `
48+
$servicesProj `
49+
$diagnosticArguments
50+
51+
if ($LASTEXITCODE) {
52+
Write-Host "##vso[task.LogIssue type=error;]API export failed. See the build logs for details."
53+
exit $LASTEXITCODE
54+
}
3755

3856
# Normalize line endings to LF in generated API listing files
3957
Write-Host "Normalizing line endings in API listing files"
40-
$apiListingFiles = Get-ChildItem -Path $apiListingFilesFilter -ErrorAction SilentlyContinue
58+
$apiListingFiles = Get-ChildItem -Path $apiListingFilesFilter
59+
$apiListingFiles | Write-Host
4160
foreach ($file in $apiListingFiles) {
4261
$content = Get-Content -Path $file.FullName -Raw
4362
if ($content) {
@@ -52,8 +71,14 @@ foreach ($file in $apiListingFiles) {
5271

5372
if ($SpellCheckPublicApiSurface) {
5473
Write-Host "Spell check public API surface"
55-
&"$PSScriptRoot/spell-check-public-api.ps1" `
56-
-ServiceDirectory $ServiceDirectory
74+
75+
if ($PSCmdlet.ParameterSetName -eq 'PackagePath') {
76+
&"$PSScriptRoot/spell-check-public-api.ps1" `
77+
-RelativePackagePath $relativePackagePath
78+
} else {
79+
&"$PSScriptRoot/spell-check-public-api.ps1" `
80+
-ServiceDirectory $relativePackagePath
81+
}
5782

5883
if ($LASTEXITCODE) {
5984
Write-Host "##vso[task.LogIssue type=error;]Spelling errors detected. To correct false positives or learn about spell checking see: https://aka.ms/azsdk/engsys/spellcheck"

eng/scripts/spell-check-public-api.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
param(
2-
[Parameter(mandatory = $false)]
3-
$ServiceDirectory = ''
2+
$ServiceDirectory = '',
3+
$RelativePackagePath = ''
44
)
55

6+
if ($ServiceDirectory -and $RelativePackagePath) {
7+
throw "Cannot specify both ServiceDirectory and RelativePackagePath parameters."
8+
}
9+
610
Set-StrictMode -Version 3.0
711
."$PSScriptRoot/../common/scripts/common.ps1"
812

913
$files = @()
1014
if ($ServiceDirectory) {
1115
$files = Get-ChildItem -Path "$PSScriptRoot/../../sdk/$ServiceDirectory/*/api/*.cs" -File
16+
} elseif ($RelativePackagePath) {
17+
$files = Get-ChildItem -Path "$PSScriptRoot/../../sdk/$RelativePackagePath/api/*.cs" -File
1218
} else {
1319
$files = Get-ChildItem -Path "$PSScriptRoot/../../sdk/*/*/api/*.cs" -File
1420
}
1521

16-
1722
Write-Host "Found $($files.Count) public API surface files to spell check."
1823
."$PSScriptRoot/../common/spelling/Invoke-Cspell.ps1" `
1924
-CSpellConfigPath "./.vscode/cspell.json" `

0 commit comments

Comments
 (0)