修改了打包图片,但未成功。vs仍显示默认图片

This commit is contained in:
zqm
2025-10-23 17:21:57 +08:00
parent 3326b419ec
commit 131946b93a
4 changed files with 26 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -13,7 +13,7 @@
<tags>thermal camera toprie 红外 热像仪 控制</tags>
<projectUrl>https://github.com/joyd/toprie-library</projectUrl>
<licenseUrl>https://opensource.org/licenses/MIT</licenseUrl>
<iconUrl>https://example.com/icon.png</iconUrl>
<icon>Toprie.png</icon>
<!-- 可以根据需要添加更多元数据,如依赖项、框架引用等 -->
<!-- <dependencies> -->
<!-- <group targetFramework=".NETFramework4.0"> -->
@@ -23,5 +23,6 @@
</metadata>
<files>
<file src="Toprie.dll" target="lib\net40\" />
<file src="Toprie.png" target="" />
</files>
</package>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 879 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -19,7 +19,9 @@ $copyright = "Copyright 2025 JoyD Technology"
$tags = @("thermal", "camera", "toprie", "红外", "热像仪", "控制")
$projectUrl = "https://github.com/joyd/toprie-library"
$licenseUrl = "https://opensource.org/licenses/MIT"
$iconUrl = "https://example.com/icon.png"
$iconFileName = "Toprie.png"
$iconSourcePath = Join-Path $scriptDir $iconFileName
$iconUrl = $iconFileName
$releaseNotes = "初始版本发布"
# 其他设置
@@ -63,6 +65,14 @@ if (!(Test-Path "$output\$actualDllName")) {
Copy-Item -Path "$output\$actualDllName" -Destination "$output\$targetDllName" -Force
Write-Host "已将 $actualDllName 复制并重命名为$targetDllName 用于打包"
# 复制图标文件到输出目录
if (Test-Path $iconSourcePath) {
Copy-Item -Path $iconSourcePath -Destination (Join-Path $output $iconFileName) -Force
Write-Host "已复制图标文件到输出目录: $iconFileName"
} else {
Write-Host "警告: 图标文件 $iconSourcePath 不存在,将使用默认图标" -ForegroundColor Yellow
}
Write-Host "2. 准备打包文件..."
# 在Output目录创建NuGet.Config文件这样dotnet nuget push命令就能正确找到它
@@ -112,7 +122,7 @@ $tempProjContent = @"
<PackageTags>$tagsString</PackageTags>
<PackageProjectUrl>$projectUrl</PackageProjectUrl>
<PackageLicenseUrl>$licenseUrl</PackageLicenseUrl>
<PackageIconUrl>$iconUrl</PackageIconUrl>
<PackageIcon>$iconUrl</PackageIcon>
<PackageReleaseNotes>$releaseNotes</PackageReleaseNotes>
<PackageOutputPath>.</PackageOutputPath>
<RestorePackagesConfig>true</RestorePackagesConfig>
@@ -154,7 +164,7 @@ $nuspecContent = @"
<tags>$tagsString</tags>
<projectUrl>$projectUrl</projectUrl>
<licenseUrl>$licenseUrl</licenseUrl>
<iconUrl>$iconUrl</iconUrl>
<icon>$iconUrl</icon>
<!-- -->
<!-- <dependencies> -->
<!-- <group targetFramework=".NETFramework4.0"> -->
@@ -164,6 +174,7 @@ $nuspecContent = @"
</metadata>
<files>
<file src="$targetDllName" target="lib\net40\" />
<file src="$iconFileName" target="" />
</files>
</package>
"@
@@ -192,6 +203,16 @@ $destDllPath = Join-Path $libDir $targetDllName
Copy-Item -Path $sourceDllPath -Destination $destDllPath -Force
Write-Host "已复制$sourceDllPath$destDllPath"
# 复制图标文件到包结构根目录
$sourceIconPath = Join-Path $output $iconFileName
$destIconPath = Join-Path $tempDir $iconFileName
if (Test-Path $sourceIconPath) {
Copy-Item -Path $sourceIconPath -Destination $destIconPath -Force
Write-Host "已复制图标文件到包结构: $destIconPath"
} else {
Write-Host "警告: 在输出目录中找不到图标文件 $sourceIconPath" -ForegroundColor Yellow
}
# 创建[Content_Types].xml文件有效nupkg必需
$contentTypesPath = Join-Path $tempDir "[Content_Types].xml"
# 使用-LiteralPath参数避免方括号被解释为通配符