Skip to content

Commit 0ff981c

Browse files
Fix Export-API.ps1 to normalize line endings to LF (Azure#52996)
* Initial plan * Add line ending normalization for GenAPI output files Co-authored-by: JoshLove-msft <[email protected]> * Integrate normalization into ExportApiInner target Co-authored-by: JoshLove-msft <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JoshLove-msft <[email protected]>
1 parent ea4b6a1 commit 0ff981c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

eng/ApiListing.targets

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@
3232
<Target
3333
Name="ExportApiInner"
3434
DependsOnTargets="Build;RemoveExistingListings;GenerateReferenceAssemblySource"
35-
Condition="'$(IsInnerBuild)' == 'true'" />
35+
Condition="'$(IsInnerBuild)' == 'true'">
36+
37+
<!-- Normalize line endings to LF using PowerShell Core -->
38+
<ItemGroup>
39+
<_ApiListingFiles Include="$(GenAPITargetPath)" Condition="Exists('$(GenAPITargetPath)')" />
40+
</ItemGroup>
41+
<Exec Command="pwsh -NoProfile -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)scripts/Normalize-LineEndings.ps1&quot; -FilePath &quot;%(_ApiListingFiles.Identity)&quot;" Condition="'@(_ApiListingFiles)' != ''" />
42+
</Target>
3643

3744
<Target Name="ExportApi" DependsOnTargets="ExportApiCrossTarget;ExportApiInner" Condition="'$(GenerateAPIListing)' == 'true'" />
3845

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env pwsh
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License.
4+
5+
param(
6+
[Parameter(Mandatory=$true)]
7+
[string]$FilePath
8+
)
9+
10+
if (Test-Path $FilePath) {
11+
$content = Get-Content -Path $FilePath -Raw
12+
# Replace CRLF with LF
13+
$content = $content -replace "`r`n", "`n"
14+
# Replace any remaining CR with LF
15+
$content = $content -replace "`r", "`n"
16+
# Write back without adding extra newline
17+
Set-Content -Path $FilePath -Value $content -NoNewline
18+
}

0 commit comments

Comments
 (0)