Skip to content

Commit ae166f7

Browse files
committed
Fix tests loading the right analyzer assemblies
1 parent c5f5b4e commit ae166f7

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/SponsorLink/SponsorLink.targets

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<ShowSponsorLinkInProject Condition="$(ShowSponsorLinkInProject) == '' and '$(TargetFramework)' == 'netstandard2.0'">true</ShowSponsorLinkInProject>
88
<!-- This ensures we expose only the main assembly in the Dependencies > Analyzers node -->
99
<MergeAnalyzerAssemblies Condition="'$(MergeAnalyzerAssemblies)' == '' and '$(Configuration)' == 'Release' and '$(OS)' == 'Windows_NT'">true</MergeAnalyzerAssemblies>
10+
<MergeAnalyzerAssemblies Condition="'$(MergeAnalyzerAssemblies)' == ''">false</MergeAnalyzerAssemblies>
1011
<!-- Whether we merge files or not, dependencies will need to be copy-local -->
1112
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1213
<!-- Make Resources visible to intellisense -->
@@ -69,17 +70,22 @@
6970
</None>
7071
</ItemGroup>
7172

73+
<PropertyGroup>
74+
<PackMergedAssemblies>true</PackMergedAssemblies>
75+
<PackMergedAssemblies Condition="'$(MergeAnalyzerAssemblies)' == 'true'">false</PackMergedAssemblies>
76+
</PropertyGroup>
77+
7278
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
73-
<PackageReference Include="Humanizer.Core" VersionOverride="2.14.1" PrivateAssets="all" Pack="false" />
79+
<PackageReference Include="Humanizer.Core" VersionOverride="2.14.1" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
7480
<PackageReference Include="Humanizer.Core.es" VersionOverride="2.14.1" PrivateAssets="all" />
75-
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" VersionOverride="7.6.2" PrivateAssets="all" Pack="false" />
81+
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" VersionOverride="7.6.2" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
7682
<PackageReference Include="ILRepack" Version="2.0.33" VersionOverride="all" PrivateAssets="all" Pack="false" />
7783
</ItemGroup>
7884

7985
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
80-
<PackageReference Include="Humanizer.Core" Version="2.14.1" PrivateAssets="all" Pack="false" />
86+
<PackageReference Include="Humanizer.Core" Version="2.14.1" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
8187
<PackageReference Include="Humanizer.Core.es" Version="2.14.1" PrivateAssets="all" />
82-
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" PrivateAssets="all" Pack="false" />
88+
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
8389
<PackageReference Include="ILRepack" Version="2.0.33" PrivateAssets="all" Pack="false" />
8490
</ItemGroup>
8591

src/SponsorLink/SponsorLink/SponsorLink.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<ImplicitUsings>disable</ImplicitUsings>
77
<GenerateDocumentationFile>false</GenerateDocumentationFile>
88
<CoreCompileDependsOn>CoreResGen;$(CoreCompileDependsOn)</CoreCompileDependsOn>
9+
<FundingPackageId>SponsorLink</FundingPackageId>
910
</PropertyGroup>
1011

1112
<PropertyGroup Label="SponsorLink">

src/SponsorLink/Tests/Tests.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
<ItemGroup>
2424
<!-- This project reference allows debugging the source generator/analyzer project -->
2525
<ProjectReference Include="..\Analyzer\Analyzer.csproj" Aliases="Analyzer" />
26-
<Analyzer Include="..\Analyzer\bin\$(Configuration)\netstandard2.0\*.dll" Visible="false" />
27-
<!-- Make sure we only annotate the primary analyzer file, as it would when the package is installed -->
28-
<Analyzer Update="@(Analyzer -&gt; WithMetadataValue('Filename', 'SponsorableLib.Analyzers'))" NuGetPackageId="SponsorableLib" />
2926
</ItemGroup>
3027

3128
<ItemGroup>
@@ -36,6 +33,15 @@
3633
<Constant Include="PublicKey" Value="$([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)keys\kzu.pub.jwk'))" />
3734
</ItemGroup>
3835

36+
<Target Name="AddBuiltAnalyzers" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun">
37+
<!-- Waits until after building the referenced analyzer project when all binaries are in the output dir -->
38+
<ItemGroup>
39+
<Analyzer Include="..\Analyzer\bin\$(Configuration)\netstandard2.0\*.dll" Visible="false" />
40+
<!-- Make sure we only annotate the primary analyzer file, as it would when the package is installed -->
41+
<Analyzer Update="@(Analyzer -&gt; WithMetadataValue('Filename', 'SponsorableLib.Analyzers'))" NuGetPackageId="SponsorableLib" />
42+
</ItemGroup>
43+
</Target>
44+
3945
<Target Name="Sample_GitConfig" Condition="'$(SourceControlInformationFeatureSupported)' == 'true'" DependsOnTargets="InitializeSourceControlInformation">
4046
<!-- Follows recommendation from Microsoft.Common.CurrentVersion.targets on how to depend on SCC info. -->
4147
<ItemGroup>

0 commit comments

Comments
 (0)