Skip to content

Commit

Permalink
SponsorLink-enabled analyzers need copylocal
Browse files Browse the repository at this point in the history
Since otherwise dependencies aren't available and cause failures. Note that on release builds, IL merging happens by default, so no unnecessary extra assemblies are packed or added as analyzer dependencies.
  • Loading branch information
kzu committed Jun 18, 2024
1 parent 23f83bd commit 7593657
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/SponsorLink/SponsorLink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ShowSponsorLinkInProject Condition="$(ShowSponsorLinkInProject) == '' and '$(TargetFramework)' == 'netstandard2.0'">true</ShowSponsorLinkInProject>
<!-- This ensures we expose only the main assembly in the Dependencies > Analyzers node -->
<MergeAnalyzerAssemblies Condition="'$(MergeAnalyzerAssemblies)' == '' and '$(Configuration)' == 'Release'">true</MergeAnalyzerAssemblies>
<!-- If we are going to merge files, we need to copy local -->
<CopyLocalLockFileAssemblies Condition="'$(MergeAnalyzerAssemblies)' == 'true'">true</CopyLocalLockFileAssemblies>
<!-- Whether we merge files or not, dependencies will need to be copy-local -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Make Resources visible to intellisense -->
<CoreCompileDependsOn>CoreResGen;$(CoreCompileDependsOn)</CoreCompileDependsOn>

Expand Down Expand Up @@ -175,4 +175,12 @@ partial class SponsorLink
</ItemGroup>
</Target>

<!-- Make sure dependencies are available in the package when not merging (i.e. local dev) -->
<Target Name="PackCopyLocalLockFileAssemblies" Condition="'$(MergeAnalyzerAssemblies)' != 'true'"
BeforeTargets="GetPackageContents" DependsOnTargets="ReferenceCopyLocalPathsOutputGroup">
<ItemGroup>
<PackageFile Include="@(ReferenceCopyLocalPathsOutputGroupOutput)" PackFolder="$(PackFolder)" />
</ItemGroup>
</Target>

</Project>

0 comments on commit 7593657

Please sign in to comment.