Skip to content

Commit 061df20

Browse files
Cyaimclaude
andcommitted
ci: 修复 C# 打包 NU5026——先 build 再 pack --no-build
真实错误(来自上传的 build-log):NU5026 待打包的 dll 未找到——因项目设了 GeneratePackageOnBuild, pack -o 在各 TFM 构建产物落盘前运行。改为先 dotnet build(构建即生成 nupkg),再 pack --no-build, 并回退到从 bin/Release 拷贝 nupkg。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a78178a commit 061df20

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

.github/workflows/release-clients.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ jobs:
8888
8989
echo "::group::C# (NuGet)"
9090
dotnet --list-sdks || true
91-
# Disable analyzers / warnings-as-errors and treat this as a plain library pack.
92-
# The client pulls Microsoft.CodeAnalysis + EnforceExtendedAnalyzerRules, whose RS-rule
93-
# enforcement differs across SDKs and fails the runner build; none of it is needed to pack.
91+
CSPROJ="$C/Cyaim.WebSocketServer.Client/Cyaim.WebSocketServer.Client.csproj"
9492
CS_PROPS="-p:RunAnalyzers=false -p:EnforceExtendedAnalyzerRules=false -p:TreatWarningsAsErrors=false -p:EnableNETAnalyzers=false"
95-
dotnet pack "$C/Cyaim.WebSocketServer.Client/Cyaim.WebSocketServer.Client.csproj" -c Release $CS_PROPS -o "$GITHUB_WORKSPACE/artifacts" \
96-
|| dotnet pack "$C/Cyaim.WebSocketServer.Client/Cyaim.WebSocketServer.Client.csproj" -c Release $CS_PROPS -p:TargetFrameworks=net8.0 -o "$GITHUB_WORKSPACE/artifacts" \
93+
# Build first (the project sets GeneratePackageOnBuild, so the build itself produces the
94+
# .nupkg), then pack --no-build. This avoids NU5026 ("dll to be packed was not found"),
95+
# which happens when pack -o runs before the per-TFM build output lands.
96+
dotnet build "$CSPROJ" -c Release $CS_PROPS
97+
dotnet pack "$CSPROJ" -c Release $CS_PROPS --no-build -o "$GITHUB_WORKSPACE/artifacts" \
98+
|| find "$C/Cyaim.WebSocketServer.Client" -path "*/bin/Release/*" -name "*.nupkg" -exec cp {} "$GITHUB_WORKSPACE/artifacts/" \; \
9799
|| echo "C# pack failed"
98100
echo "::endgroup::"
99101

0 commit comments

Comments
 (0)