Skip to content

Commit cc14695

Browse files
committed
fix: NuGet symbols package publishing failure
- IO csproj: remove DependsOnTargets="Build" from PackSourceGenerator target, use $(MSBuildThisFileDirectory) for reliable path resolution - SG csproj: add IsPackable=false to prevent source generator from being published as standalone NuGet package - CI: clean bin/obj before scanning, limit to ./src, drop deprecated --include-source flag, merge nupkg+snupkg push into single atomic call
1 parent e9b324a commit cc14695

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

azure-pipelines.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,20 @@ jobs:
6464
inputs:
6565
targetType: 'inline'
6666
script: |
67-
# 打包
68-
Get-ChildItem -Path ./ -Recurse |
67+
# 清理 bin/obj 残留(避免 BenchmarkDotNet/IISExpress 等自动生成的 csproj 被误打包)
68+
Get-ChildItem -Path ./bin, ./obj -Recurse -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
69+
70+
# 打包(仅 src/ 下的非 Test 项目)
71+
Get-ChildItem -Path ./src -Recurse |
6972
Where-Object { $_.Name.EndsWith(".csproj") -and !$_.Name.Contains("Test") } |
7073
ForEach-Object -Process {
7174
Write-Host $_.Name
72-
dotnet pack $_.FullName -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --include-source --output $(Build.ArtifactStagingDirectory) -c $(BuildConfiguration)
75+
dotnet pack $_.FullName --output $(Build.ArtifactStagingDirectory) -c $(BuildConfiguration)
7376
}
7477
ls $(Build.ArtifactStagingDirectory)
7578
76-
#推包
77-
dotnet nuget push $(Build.ArtifactStagingDirectory)\*.nupkg -k $env:NUGET_API_KEY --skip-duplicate -s https://api.nuget.org/v3/index.json
79+
#推包(nupkg + snupkg 原子推送)
80+
dotnet nuget push $(Build.ArtifactStagingDirectory)\*.nupkg -k $env:NUGET_API_KEY --skip-duplicate -s https://api.nuget.org/v3/index.json
7881
failOnStderr: true
7982
showWarnings: true
8083
ignoreLASTEXITCODE: true

src/Magicodes.IE.IO.SourceGenerator/Magicodes.IE.IO.SourceGenerator.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<DevelopmentDependency>true</DevelopmentDependency>
1111
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
1212
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
13+
<IsPackable>false</IsPackable>
1314
<PackageId>Magicodes.IE.IO.SourceGenerator</PackageId>
1415
<Description>Source generator for Magicodes.IE.IO — generates typed property getters at compile time, eliminating Expression.Compile runtime reflection.</Description>
1516
</PropertyGroup>

src/Magicodes.IE.IO/Magicodes.IE.IO.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@
2525
ReferenceOutputAssembly="false" />
2626
</ItemGroup>
2727

28-
<Target Name="PackSourceGenerator"
29-
BeforeTargets="_GetPackageFiles"
30-
DependsOnTargets="Build">
28+
<!--
29+
Pack the source generator as a NuGet analyzer.
30+
SG is already a ProjectReference — dotnet pack builds it during the Build phase,
31+
so we do NOT add DependsOnTargets="Build" here (it would double-build and leak
32+
the SG's PDB into the .snupkg, failing NuGet symbol validation).
33+
-->
34+
<Target Name="PackSourceGenerator" BeforeTargets="_GetPackageFiles">
3135
<ItemGroup>
32-
<None Include="../Magicodes.IE.IO.SourceGenerator/bin/$(Configuration)/netstandard2.0/Magicodes.IE.IO.SourceGenerator.dll"
36+
<None Include="$(MSBuildThisFileDirectory)../Magicodes.IE.IO.SourceGenerator/bin/$(Configuration)/netstandard2.0/Magicodes.IE.IO.SourceGenerator.dll"
3337
Pack="true"
3438
PackagePath="analyzers/dotnet/cs/"
3539
Visible="false" />

0 commit comments

Comments
 (0)