Skip to content

Commit 4d79212

Browse files
authored
feat: 自动为所有已安装的OTAPI添加XML文档
* 将PowellShell脚本中硬编码路径改为遍历所有版本的OTA目录
1 parent fe55370 commit 4d79212

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,24 @@ jobs:
2323
run: |
2424
dotnet build OTAPIXmlDocument.sln -c Release
2525
ota_content=$(cat OTAPI/OTAPI.xml)
26-
ota_path=".nuget/packages/otapi.upcoming/3.1.20/lib/net6.0"
2726
powershell_script=$(cat <<EOL
2827
\$OTA = @"
2928
$ota_content
3029
"@
31-
if (Test-Path -Path "\$env:USERPROFILE/$ota_path/OTAPI.dll") {
32-
New-Item -Path "\$env:USERPROFILE/$ota_path" -Name "OTAPI.xml" -ItemType "file" -Force
33-
Set-Content -Path "\$env:USERPROFILE/$ota_path/OTAPI.xml" -Value \$OTA
34-
Write-Host "OTAPI.xml 文件已安装到: \$env:USERPROFILE/.nuget/packages/otapi.upcoming/3.1.20/lib/net6.0/OTAPI.xml。"
30+
\$dllFiles = Get-ChildItem -Path "\$env:USERPROFILE/.nuget/packages/otapi.upcoming" -Recurse -Filter "OTAPI.dll"
31+
32+
if (\$dllFiles.Count -eq 0) {
33+
Write-Host "未找到任何 OTAPI.dll 文件。"
3534
} else {
36-
Write-Host "OTAPI.dll 文件不存在。"
35+
foreach (\$dllFile in \$dllFiles) {
36+
\$targetDir = \$dllFile.DirectoryName
37+
\$xmlPath = Join-Path -Path \$targetDir -ChildPath "OTAPI.xml"
38+
39+
New-Item -Path \$xmlPath -ItemType "file" -Force | Out-Null
40+
Set-Content -Path \$xmlPath -Value \$OTA
41+
42+
Write-Host "已创建 OTAPI.xml 在: \$xmlPath"
43+
}
3744
}
3845
Pause
3946
EOL

0 commit comments

Comments
 (0)