Centralize packing source generators in .targets file

このコミットが含まれているのは:
Sergio Pedri committed 2023-04-22 12:15:58 +02:00
1 親 129268ffb6
コミット cf478e4421
4ファイル変更
+17 -30

検索条件に一致するファイルはありません

+17
ファイルの表示
@@ -2,6 +2,23 @@
<Project>
<Import Project="..\build\Directory.Build.targets" />
<!-- Check whether there is a source generator that should be packed with the project -->
<PropertyGroup Condition="$(IsPackagedProject)">
<IsSourceGeneratorAvailableForPacking>false</IsSourceGeneratorAvailableForPacking>
<IsSourceGeneratorAvailableForPacking Condition="Exists('..\$(MSBuildProjectName).SourceGenerators')">true</IsSourceGeneratorAvailableForPacking>
<SourceGeneratorReferenceTargetFramework Condition="$(IsSourceGeneratorAvailableForPacking)">$(TargetFrameworks.Split(';')[0].Trim())</SourceGeneratorReferenceTargetFramework>
</PropertyGroup>
<!-- Pack the source generator, if present -->
<ItemGroup Condition="'$(IsSourceGeneratorAvailableForPacking)' == 'true'" Label="Package">
<!-- Source generator reference (to trigger building the generator) -->
<ProjectReference Condition="'$(TargetFramework)' == '$(SourceGeneratorReferenceTargetFramework)'" Include="..\$(MSBuildProjectName).SourceGenerators\$(MSBuildProjectName).SourceGenerators.csproj" ReferenceOutputAssembly="false" />
<!-- Pack the source generator from its output directory -->
<None Include="..\$(MSBuildProjectName).SourceGenerators\bin\$(Configuration)\$(SourceGeneratorReferenceTargetFramework)\$(MSBuildProjectName).SourceGenerators.dll" PackagePath="analyzers\dotnet\cs" Pack="true" Visible="false" />
</ItemGroup>
<!--
Enable trimming support on .NET 6 (we need to use StartsWith since it
could be a Windows TFM too). This can't be in a target unlike the other