From 98ff31fab822d93650132ce169e498b125fcdf7c Mon Sep 17 00:00:00 2001 From: zqm Date: Tue, 23 Dec 2025 10:02:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85=E4=B8=AD=E5=8C=85=E5=90=ABpd?= =?UTF-8?q?b=E5=92=8Cxml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CS/Framework4.0/Utils/publish-nuget.ps1 | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Windows/CS/Framework4.0/Utils/publish-nuget.ps1 b/Windows/CS/Framework4.0/Utils/publish-nuget.ps1 index 852737a..990879f 100644 --- a/Windows/CS/Framework4.0/Utils/publish-nuget.ps1 +++ b/Windows/CS/Framework4.0/Utils/publish-nuget.ps1 @@ -60,6 +60,11 @@ if (!(Test-Path $output)) { Write-Host "清理之前的构建文件.." if (Test-Path "$output\$actualDllName") { Remove-Item -Path "$output\$actualDllName" -Force } if (Test-Path "$output\$targetDllName") { Remove-Item -Path "$output\$targetDllName" -Force } +# 添加清理pdb和xml文件 +$actualPdbName = [System.IO.Path]::ChangeExtension($actualDllName, ".pdb") +$actualXmlName = [System.IO.Path]::ChangeExtension($actualDllName, ".xml") +if (Test-Path "$output\$actualPdbName") { Remove-Item -Path "$output\$actualPdbName" -Force } +if (Test-Path "$output\$actualXmlName") { Remove-Item -Path "$output\$actualXmlName" -Force } if (Test-Path "$output\$nupkgFileName") { Remove-Item -Path "$output\$nupkgFileName" -Force } if (Test-Path "$output\$packageId.nuspec") { Remove-Item -Path "$output\$packageId.nuspec" -Force } @@ -79,6 +84,18 @@ if (!(Test-Path "$output\$actualDllName")) { exit 1 } +# 验证pdb和xml文件是否存在 +$actualPdbName = [System.IO.Path]::ChangeExtension($actualDllName, ".pdb") +$actualXmlName = [System.IO.Path]::ChangeExtension($actualDllName, ".xml") + +if (!(Test-Path "$output\$actualPdbName")) { + Write-Host "警告: 在输出目录中找不到$actualPdbName! 将继续打包但缺少调试信息" -ForegroundColor Yellow +} + +if (!(Test-Path "$output\$actualXmlName")) { + Write-Host "警告: 在输出目录中找不到$actualXmlName! 将继续打包但缺少文档注释" -ForegroundColor Yellow +} + # 直接使用实际DLL文件,不进行重命名 Write-Host "使用实际DLL文件: $actualDllName 用于打包" @@ -194,6 +211,8 @@ $nuspecContent = @" + + @@ -223,6 +242,24 @@ $destDllPath = Join-Path $libDir $targetDllName Copy-Item -Path $sourceDllPath -Destination $destDllPath -Force Write-Host "已复制$sourceDllPath 到$destDllPath" +# 复制pdb文件到包结构中 +$targetPdbName = [System.IO.Path]::ChangeExtension($targetDllName, ".pdb") +$sourcePdbPath = Join-Path $output $targetPdbName +$destPdbPath = Join-Path $libDir $targetPdbName +if (Test-Path $sourcePdbPath) { + Copy-Item -Path $sourcePdbPath -Destination $destPdbPath -Force + Write-Host "已复制$sourcePdbPath 到$destPdbPath" +} + +# 复制xml文件到包结构中 +$targetXmlName = [System.IO.Path]::ChangeExtension($targetDllName, ".xml") +$sourceXmlPath = Join-Path $output $targetXmlName +$destXmlPath = Join-Path $libDir $targetXmlName +if (Test-Path $sourceXmlPath) { + Copy-Item -Path $sourceXmlPath -Destination $destXmlPath -Force + Write-Host "已复制$sourceXmlPath 到$destXmlPath" +} + # 复制图标文件到包结构根目录 $sourceIconPath = Join-Path $output $iconFileName $destIconPath = Join-Path $tempDir $iconFileName