Skip to content

Commit d27871c

Browse files
authored
Pack generator DLLs via post-build target to fix empty analyzer packages (#9785)
1 parent 1c8cbad commit d27871c

4 files changed

Lines changed: 48 additions & 15 deletions

File tree

src/CookieCrumble/src/CookieCrumble.Xunit/CookieCrumble.Xunit.csproj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@
1717
<ProjectReference Include="../CookieCrumble.Analyzers/CookieCrumble.Analyzers.csproj" PrivateAssets="All" ExcludeAssets="compile;runtime" />
1818
</ItemGroup>
1919

20-
<ItemGroup>
21-
<!-- Package the generator in the analyzer directory of the nuget package -->
22-
<None Include="$(OutputPath)\net10.0\CookieCrumble.Analyzers.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
23-
</ItemGroup>
20+
<PropertyGroup>
21+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddGeneratorToPackage</TargetsForTfmSpecificContentInPackage>
22+
</PropertyGroup>
23+
24+
<!-- Package the generator into the analyzer directory of the NuGet package.
25+
Runs after pack's build phase has populated $(OutputPath).
26+
This project multi-targets, so emit the analyzer only once (the per-TFM target
27+
fires per framework) to avoid a duplicate package-path collision. -->
28+
<Target Name="_AddGeneratorToPackage">
29+
<ItemGroup>
30+
<TfmSpecificPackageFile Condition="'$(TargetFramework)' == 'net10.0'" Include="$(OutputPath)CookieCrumble.Analyzers.dll" PackagePath="analyzers/dotnet/cs" />
31+
</ItemGroup>
32+
</Target>
2433

2534
</Project>

src/CookieCrumble/src/CookieCrumble.Xunit3/CookieCrumble.Xunit3.csproj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@
1616
<ProjectReference Include="../CookieCrumble.Analyzers/CookieCrumble.Analyzers.csproj" PrivateAssets="All" ExcludeAssets="compile;runtime" />
1717
</ItemGroup>
1818

19-
<ItemGroup>
20-
<!-- Package the generator in the analyzer directory of the nuget package -->
21-
<None Include="$(OutputPath)\net10.0\CookieCrumble.Analyzers.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
22-
</ItemGroup>
19+
<PropertyGroup>
20+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddGeneratorToPackage</TargetsForTfmSpecificContentInPackage>
21+
</PropertyGroup>
22+
23+
<!-- Package the generator into the analyzer directory of the NuGet package.
24+
Runs after pack's build phase has populated $(OutputPath).
25+
This project multi-targets, so emit the analyzer only once (the per-TFM target
26+
fires per framework) to avoid a duplicate package-path collision. -->
27+
<Target Name="_AddGeneratorToPackage">
28+
<ItemGroup>
29+
<TfmSpecificPackageFile Condition="'$(TargetFramework)' == 'net10.0'" Include="$(OutputPath)CookieCrumble.Analyzers.dll" PackagePath="analyzers/dotnet/cs" />
30+
</ItemGroup>
31+
</Target>
2332

2433
</Project>

src/HotChocolate/Core/src/Types.Analyzers/HotChocolate.Types.Analyzers.csproj

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@
2828
<PackageReference Include="Microsoft.Bcl.HashCode" VersionOverride="1.1.0" PrivateAssets="all" />
2929
</ItemGroup>
3030

31-
<ItemGroup>
32-
<!-- Package the generator in the analyzer directory of the nuget package -->
33-
<None Include="$(OutputPath)\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
34-
</ItemGroup>
31+
<PropertyGroup>
32+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddGeneratorToPackage</TargetsForTfmSpecificContentInPackage>
33+
</PropertyGroup>
34+
35+
<!-- Package the generator into the analyzer directory of the NuGet package.
36+
Runs after pack's build phase has populated $(OutputPath). -->
37+
<Target Name="_AddGeneratorToPackage">
38+
<ItemGroup>
39+
<TfmSpecificPackageFile Include="$(OutputPath)*.dll" PackagePath="analyzers/dotnet/cs" />
40+
</ItemGroup>
41+
</Target>
3542

3643
<ItemGroup>
3744
<EmbeddedResource Update="Properties\SourceGenResources.resx">

src/Mocha/src/Mocha.Analyzers/Mocha.Analyzers.csproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@
1818
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
1919
<PackageReference Include="Microsoft.Bcl.HashCode" VersionOverride="1.1.0" PrivateAssets="all" />
2020
</ItemGroup>
21-
<ItemGroup>
22-
<None Include="$(OutputPath)\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
23-
</ItemGroup>
21+
<PropertyGroup>
22+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddGeneratorToPackage</TargetsForTfmSpecificContentInPackage>
23+
</PropertyGroup>
24+
25+
<!-- Package the generator into the analyzer directory of the NuGet package.
26+
Runs after pack's build phase has populated $(OutputPath). -->
27+
<Target Name="_AddGeneratorToPackage">
28+
<ItemGroup>
29+
<TfmSpecificPackageFile Include="$(OutputPath)*.dll" PackagePath="analyzers/dotnet/cs" />
30+
</ItemGroup>
31+
</Target>
2432
</Project>

0 commit comments

Comments
 (0)