Skip to content

Commit ba2fd92

Browse files
Fix packaging
1 parent a5847cb commit ba2fd92

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

src/CarpaNet.SourceGen/CarpaNet.SourceGen.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<ProjectReference Include="..\CarpaNet.BuildTasks\CarpaNet.BuildTasks.csproj"
2121
ReferenceOutputAssembly="false"
2222
SkipGetTargetFrameworkProperties="true"
23-
SetTargetFramework="TargetFramework=net8.0" />
23+
GlobalPropertiesToRemove="TargetFramework" />
2424
</ItemGroup>
2525

2626
<Import Project="..\..\Version.props" />

src/CarpaNet/CarpaNet.csproj

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<Description>.NET ATProtocol Library, built for bindings with source generators.</Description>
1212
<DevelopmentDependency>false</DevelopmentDependency>
1313
<SuppressDependenciesWhenPacking>false</SuppressDependenciesWhenPacking>
14+
<NoPackageAnalysis>true</NoPackageAnalysis>
15+
<!-- Hook into the pack pipeline to add analyzer, targets, and task files -->
16+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddSourceGenPackageFiles</TargetsForTfmSpecificContentInPackage>
1417
</PropertyGroup>
1518

1619
<ItemGroup>
@@ -29,32 +32,29 @@
2932
<ProjectReference Include="..\CarpaNet.SourceGen\CarpaNet.SourceGen.csproj"
3033
ReferenceOutputAssembly="false"
3134
SkipGetTargetFrameworkProperties="true"
32-
SetTargetFramework="TargetFramework=netstandard2.0" />
33-
<ProjectReference Include="..\CarpaNet.BuildTasks\CarpaNet.BuildTasks.csproj"
34-
ReferenceOutputAssembly="false"
35-
SkipGetTargetFrameworkProperties="true"
36-
SetTargetFramework="TargetFramework=net8.0" />
37-
</ItemGroup>
38-
39-
<!-- Pack the source generator analyzer DLLs -->
40-
<ItemGroup>
41-
<None Include="..\CarpaNet.SourceGen\$(OutputPath)\CarpaNet.SourceGen.dll"
42-
Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
43-
<None Include="$(PkgSystem_Text_Json)\lib\netstandard2.0\System.Text.Json.dll"
44-
Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
35+
GlobalPropertiesToRemove="TargetFramework" />
4536
</ItemGroup>
4637

47-
<!-- Pack build targets -->
48-
<ItemGroup>
49-
<None Include="build\CarpaNet.targets" Pack="true" PackagePath="build\" Visible="false" />
50-
<None Include="build\CarpaNet.targets" Pack="true" PackagePath="buildTransitive\" Visible="false" />
51-
</ItemGroup>
52-
53-
<!-- Pack the build task DLL -->
54-
<ItemGroup>
55-
<None Include="..\CarpaNet.BuildTasks\bin\$(Configuration)\net8.0\CarpaNet.BuildTasks.dll"
56-
Pack="true" PackagePath="tasks\net8.0\" Visible="false" />
57-
</ItemGroup>
38+
<!-- Add source generator, build targets, and build tasks to the NuGet package.
39+
Uses TargetsForTfmSpecificContentInPackage so properties like PkgSystem_Text_Json
40+
are resolved at pack time. Only added for one TFM to avoid duplicates. -->
41+
<Target Name="_AddSourceGenPackageFiles" Condition="'$(TargetFramework)' == 'netstandard2.0'">
42+
<ItemGroup>
43+
<!-- Analyzer DLLs -->
44+
<TfmSpecificPackageFile Include="..\CarpaNet.SourceGen\bin\$(Configuration)\netstandard2.0\CarpaNet.SourceGen.dll"
45+
PackagePath="analyzers/dotnet/cs" />
46+
<TfmSpecificPackageFile Include="$(PkgSystem_Text_Json)\lib\netstandard2.0\System.Text.Json.dll"
47+
PackagePath="analyzers/dotnet/cs" />
48+
<!-- Build targets -->
49+
<TfmSpecificPackageFile Include="build\CarpaNet.targets"
50+
PackagePath="build" />
51+
<TfmSpecificPackageFile Include="build\CarpaNet.targets"
52+
PackagePath="buildTransitive" />
53+
<!-- Build task DLL -->
54+
<TfmSpecificPackageFile Include="..\CarpaNet.BuildTasks\bin\$(Configuration)\net8.0\CarpaNet.BuildTasks.dll"
55+
PackagePath="tasks/net8.0" />
56+
</ItemGroup>
57+
</Target>
5858

5959
<Import Project="..\..\Version.props" />
6060
</Project>

0 commit comments

Comments
 (0)