修改发布脚本

This commit is contained in:
zqm
2026-01-04 15:18:00 +08:00
parent ad83dbec4f
commit 2c4bfdce55
3 changed files with 20 additions and 35 deletions

View File

@@ -33,6 +33,6 @@ using System.Runtime.InteropServices;
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")] [assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")] [assembly: AssemblyFileVersion("1.0.0.4")]
// NuGet包相关信息已在项目文件中配置 // NuGet包相关信息已在项目文件中配置

View File

@@ -42,14 +42,17 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>$(AssemblyName).xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

View File

@@ -7,7 +7,6 @@ $output = Join-Path $scriptDir "Output"
$server = "http://47.111.181.23:8081/repository/nuget-releases/" $server = "http://47.111.181.23:8081/repository/nuget-releases/"
$key = "admin:admin" $key = "admin:admin"
$actualDllName = "JoyD.Windows.CS.Toprie.dll" $actualDllName = "JoyD.Windows.CS.Toprie.dll"
$targetDllName = "Toprie.dll"
# 从AssemblyInfo.cs获取版本号 # 从AssemblyInfo.cs获取版本号
$assemblyInfoPath = "$scriptDir\Toprie\Properties\AssemblyInfo.cs" $assemblyInfoPath = "$scriptDir\Toprie\Properties\AssemblyInfo.cs"
@@ -62,24 +61,19 @@ if (!(Test-Path $output)) {
# 定义pdb和xml文件名称 # 定义pdb和xml文件名称
$actualPdbName = $actualDllName -replace "\.dll$", ".pdb" $actualPdbName = $actualDllName -replace "\.dll$", ".pdb"
$actualXmlName = $actualDllName -replace "\.dll$", ".xml" $actualXmlName = $actualDllName -replace "\.dll$", ".xml"
$targetPdbName = $targetDllName -replace "\.dll$", ".pdb"
$targetXmlName = $targetDllName -replace "\.dll$", ".xml"
# 清理之前的构建文件 # 清理之前的构建文件
Write-Host "清理之前的构建文件.." Write-Host "清理之前的构建文件.."
if (Test-Path "$output\$actualDllName") { Remove-Item -Path "$output\$actualDllName" -Force } if (Test-Path "$output\$actualDllName") { Remove-Item -Path "$output\$actualDllName" -Force }
if (Test-Path "$output\$actualPdbName") { Remove-Item -Path "$output\$actualPdbName" -Force } 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\$actualXmlName") { Remove-Item -Path "$output\$actualXmlName" -Force }
if (Test-Path "$output\$targetDllName") { Remove-Item -Path "$output\$targetDllName" -Force }
if (Test-Path "$output\$targetPdbName") { Remove-Item -Path "$output\$targetPdbName" -Force }
if (Test-Path "$output\$targetXmlName") { Remove-Item -Path "$output\$targetXmlName" -Force }
if (Test-Path "$output\$nupkgFileName") { Remove-Item -Path "$output\$nupkgFileName" -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 } if (Test-Path "$output\$packageId.nuspec") { Remove-Item -Path "$output\$packageId.nuspec" -Force }
# 构建项目确保生成pdb和xml文件 # 构建项目确保生成pdb和xml文件
Write-Host "1. 正在构建项目..." Write-Host "1. 正在构建项目..."
Write-Host "当前目录: $scriptDir" Write-Host "当前目录: $scriptDir"
dotnet build "$scriptDir\Toprie\Toprie.csproj" -c Release -o "$output" /p:DebugSymbols=true /p:DebugType=full /p:DocumentationFile=true dotnet build "$scriptDir\Toprie\Toprie.csproj" -c Release -o "$output" /p:DebugSymbols=true /p:DebugType=full /p:DocumentationFile=JoyD.Windows.CS.Toprie.xml
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
Write-Host "错误: 构建失败!" -ForegroundColor Red Write-Host "错误: 构建失败!" -ForegroundColor Red
@@ -92,20 +86,8 @@ if (!(Test-Path "$output\$actualDllName")) {
exit 1 exit 1
} }
# 复制DLL并重命名用于打包 # 直接使用原始文件名,无需复制重命名
Copy-Item -Path "$output\$actualDllName" -Destination "$output\$targetDllName" -Force Write-Host "使用原始文件名: $actualDllName"
Write-Host "已将 $actualDllName 复制并重命名为$targetDllName 用于打包"
# 复制PDB和XML文件并重命名用于打包
if (Test-Path "$output\$actualPdbName") {
Copy-Item -Path "$output\$actualPdbName" -Destination "$output\$targetPdbName" -Force
Write-Host "已将 $actualPdbName 复制并重命名为$targetPdbName 用于打包"
}
if (Test-Path "$output\$actualXmlName") {
Copy-Item -Path "$output\$actualXmlName" -Destination "$output\$targetXmlName" -Force
Write-Host "已将 $actualXmlName 复制并重命名为$targetXmlName 用于打包"
}
# 复制图标文件到输出目录 # 复制图标文件到输出目录
if (Test-Path $iconSourcePath) { if (Test-Path $iconSourcePath) {
@@ -174,9 +156,9 @@ $tempProjContent = @"
<NoBuild>true</NoBuild> <NoBuild>true</NoBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Include="$targetDllName" Pack="true" PackagePath="lib\net40\$targetDllName" /> <Content Include="$actualDllName" Pack="true" PackagePath="lib\net40\$actualDllName" />
<Content Include="$targetPdbName" Pack="true" PackagePath="lib\net40\$targetPdbName" /> <Content Include="$actualPdbName" Pack="true" PackagePath="lib\net40\$actualPdbName" />
<Content Include="$targetXmlName" Pack="true" PackagePath="lib\net40\$targetXmlName" /> <Content Include="$actualXmlName" Pack="true" PackagePath="lib\net40\$actualXmlName" />
<Content Include="$iconFileName" Pack="true" PackagePath="$iconFileName" /> <Content Include="$iconFileName" Pack="true" PackagePath="$iconFileName" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -220,9 +202,9 @@ $nuspecContent = @"
<!-- </dependencies> --> <!-- </dependencies> -->
</metadata> </metadata>
<files> <files>
<file src="$targetDllName" target="lib\net40\" /> <file src="$actualDllName" target="lib\net40\" />
<file src="$targetPdbName" target="lib\net40\" /> <file src="$actualPdbName" target="lib\net40\" />
<file src="$targetXmlName" target="lib\net40\" /> <file src="$actualXmlName" target="lib\net40\" />
<file src="$iconFileName" target="\" /> <file src="$iconFileName" target="\" />
</files> </files>
</package> </package>
@@ -247,22 +229,22 @@ if (!(Test-Path $libDir)) {
} }
# 复制DLL到包结构中 # 复制DLL到包结构中
$sourceDllPath = Join-Path $output $targetDllName $sourceDllPath = Join-Path $output $actualDllName
$destDllPath = Join-Path $libDir $targetDllName $destDllPath = Join-Path $libDir $actualDllName
Copy-Item -Path $sourceDllPath -Destination $destDllPath -Force Copy-Item -Path $sourceDllPath -Destination $destDllPath -Force
Write-Host "已复制$sourceDllPath$destDllPath" Write-Host "已复制$sourceDllPath$destDllPath"
# 复制PDB文件到包结构中 # 复制PDB文件到包结构中
$sourcePdbPath = Join-Path $output $targetPdbName $sourcePdbPath = Join-Path $output $actualPdbName
$destPdbPath = Join-Path $libDir $targetPdbName $destPdbPath = Join-Path $libDir $actualPdbName
if (Test-Path $sourcePdbPath) { if (Test-Path $sourcePdbPath) {
Copy-Item -Path $sourcePdbPath -Destination $destPdbPath -Force Copy-Item -Path $sourcePdbPath -Destination $destPdbPath -Force
Write-Host "已复制$sourcePdbPath$destPdbPath" Write-Host "已复制$sourcePdbPath$destPdbPath"
} }
# 复制XML文件到包结构中 # 复制XML文件到包结构中
$sourceXmlPath = Join-Path $output $targetXmlName $sourceXmlPath = Join-Path $output $actualXmlName
$destXmlPath = Join-Path $libDir $targetXmlName $destXmlPath = Join-Path $libDir $actualXmlName
if (Test-Path $sourceXmlPath) { if (Test-Path $sourceXmlPath) {
Copy-Item -Path $sourceXmlPath -Destination $destXmlPath -Force Copy-Item -Path $sourceXmlPath -Destination $destXmlPath -Force
Write-Host "已复制$sourceXmlPath$destXmlPath" Write-Host "已复制$sourceXmlPath$destXmlPath"