Added targets that allow for the runtime dependencies of ProjectReference'd analyzers to be passed to the compiler

このコミットが含まれているのは:
SingleAccretion committed 2020-12-14 15:25:57 +03:00
1 親 1d9fe9a429
コミット 992355f382
2ファイル変更
+47 -7

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

+40
ファイルの表示
@@ -0,0 +1,40 @@
<Project>
<Target Name="GetRuntimeDependenciesForAnalyzer"
DependsOnTargets="ComputeResolvedFilesToPublishList"
Outputs="@(ResolvedAssemblyToPublish)">
<ItemGroup>
<ResolvedAssemblyToPublish Include="@(ResolvedFileToPublish->'%(FullPath)')"
Condition="'%(Extension)' == '.dll' AND '%(FileName)' != $(MSBuildProjectName)" />
</ItemGroup>
</Target>
<Target Name="ComputeAnalyzerProjectReferences"
AfterTargets="AfterResolveReferences">
<ItemGroup>
<AnalyzerProjectReference Include="@(_MSBuildProjectReferenceExistent)"
Condition="'%(_MSBuildProjectReferenceExistent.OutputItemType)' == 'Analyzer'" />
</ItemGroup>
</Target>
<Target Name="PassAnalyzerDependenciesToCompiler"
Condition="'@(AnalyzerProjectReference)' != ''"
AfterTargets="ComputeAnalyzerProjectReferences"
BeforeTargets="CoreCompile">
<MSBuild
Projects="@(AnalyzerProjectReference)"
Targets="GetRuntimeDependenciesForAnalyzer"
RemoveProperties="%(AnalyzerProjectReference.GlobalPropertiesToRemove)">
<Output TaskParameter="TargetOutputs" ItemName="AnalyzerDependency"/>
</MSBuild>
<Message Text="Analyzer project references for $(MSBuildProjectName):" Importance="High" />
<Message Text=" %(AnalyzerProjectReference.FileName)" Importance="High" />
<Message Text="Resolved analyzer dependencies:" Importance="High" />
<Message Text=" %(AnalyzerDependency.FileName)" Importance="High" />
<ItemGroup>
<Analyzer Include="@(AnalyzerDependency)" />
</ItemGroup>
</Target>
</Project>
+7 -7
ファイルの表示
@@ -10,19 +10,19 @@
<!--This is needed so that the packaging for the source generator is correct. We want to have the package references
of this project be private when packing the source generator (the nugetizer infrastructure recognizes that and
packages the dependencies directly alongside the main binary), and public dependencies when building for the main
project. Right now this is conditioned on the target framework, so this property is primarily for readability.-->
<BuildingForSourceGenerator>false</BuildingForSourceGenerator>
<BuildingForSourceGenerator Condition="'$(TargetFramework)' == 'netstandard2.0'">true</BuildingForSourceGenerator>
packages the dependencies directly alongside the main binary), and public dependencies when packing the main project.
Notably, when building the source generator for sample projects via ProjectReferences, we do not want the packages to be private.-->
<BuildingPackageForSourceGenerator>false</BuildingPackageForSourceGenerator>
<BuildingPackageForSourceGenerator Condition="'$(TargetFramework)' == 'netstandard2.0' AND '$(BuildingPackage)' == 'true'">true</BuildingPackageForSourceGenerator>
<PackSymbols Condition="'$(BuildingForSourceGenerator)' == true">false</PackSymbols>
<PackSymbols Condition="'$(BuildingPackageForSourceGenerator)' == 'true'">false</PackSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit" Version="7.0.0-preview4" />
<!--Hide the package references when this assembly is being built for the source generator-->
<PackageReference Condition="'$(BuildingForSourceGenerator)' == 'true'" Update="@(PackageReference)" PrivateAssets="all" />
<!--Hide the package references when this assembly is being packed with the source generator-->
<PackageReference Condition="'$(BuildingPackageForSourceGenerator)' == 'true'" Update="@(PackageReference)" PrivateAssets="all" />
</ItemGroup>
</Project>