Skip to content

Commit

Permalink
Fix tests loading the right analyzer assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Jul 6, 2024
1 parent c5f5b4e commit ae166f7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/SponsorLink/SponsorLink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<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' and '$(OS)' == 'Windows_NT'">true</MergeAnalyzerAssemblies>
<MergeAnalyzerAssemblies Condition="'$(MergeAnalyzerAssemblies)' == ''">false</MergeAnalyzerAssemblies>
<!-- Whether we merge files or not, dependencies will need to be copy-local -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Make Resources visible to intellisense -->
Expand Down Expand Up @@ -69,17 +70,22 @@
</None>
</ItemGroup>

<PropertyGroup>
<PackMergedAssemblies>true</PackMergedAssemblies>
<PackMergedAssemblies Condition="'$(MergeAnalyzerAssemblies)' == 'true'">false</PackMergedAssemblies>
</PropertyGroup>

<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
<PackageReference Include="Humanizer.Core" VersionOverride="2.14.1" PrivateAssets="all" Pack="false" />
<PackageReference Include="Humanizer.Core" VersionOverride="2.14.1" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
<PackageReference Include="Humanizer.Core.es" VersionOverride="2.14.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" VersionOverride="7.6.2" PrivateAssets="all" Pack="false" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" VersionOverride="7.6.2" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
<PackageReference Include="ILRepack" Version="2.0.33" VersionOverride="all" PrivateAssets="all" Pack="false" />
</ItemGroup>

<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
<PackageReference Include="Humanizer.Core" Version="2.14.1" PrivateAssets="all" Pack="false" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
<PackageReference Include="Humanizer.Core.es" Version="2.14.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" PrivateAssets="all" Pack="false" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
<PackageReference Include="ILRepack" Version="2.0.33" PrivateAssets="all" Pack="false" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions src/SponsorLink/SponsorLink/SponsorLink.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ImplicitUsings>disable</ImplicitUsings>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<CoreCompileDependsOn>CoreResGen;$(CoreCompileDependsOn)</CoreCompileDependsOn>
<FundingPackageId>SponsorLink</FundingPackageId>
</PropertyGroup>

<PropertyGroup Label="SponsorLink">
Expand Down
12 changes: 9 additions & 3 deletions src/SponsorLink/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
<ItemGroup>
<!-- This project reference allows debugging the source generator/analyzer project -->
<ProjectReference Include="..\Analyzer\Analyzer.csproj" Aliases="Analyzer" />
<Analyzer Include="..\Analyzer\bin\$(Configuration)\netstandard2.0\*.dll" Visible="false" />
<!-- Make sure we only annotate the primary analyzer file, as it would when the package is installed -->
<Analyzer Update="@(Analyzer -&gt; WithMetadataValue('Filename', 'SponsorableLib.Analyzers'))" NuGetPackageId="SponsorableLib" />
</ItemGroup>

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

<Target Name="AddBuiltAnalyzers" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun">
<!-- Waits until after building the referenced analyzer project when all binaries are in the output dir -->
<ItemGroup>
<Analyzer Include="..\Analyzer\bin\$(Configuration)\netstandard2.0\*.dll" Visible="false" />
<!-- Make sure we only annotate the primary analyzer file, as it would when the package is installed -->
<Analyzer Update="@(Analyzer -&gt; WithMetadataValue('Filename', 'SponsorableLib.Analyzers'))" NuGetPackageId="SponsorableLib" />
</ItemGroup>
</Target>

<Target Name="Sample_GitConfig" Condition="'$(SourceControlInformationFeatureSupported)' == 'true'" DependsOnTargets="InitializeSourceControlInformation">
<!-- Follows recommendation from Microsoft.Common.CurrentVersion.targets on how to depend on SCC info. -->
<ItemGroup>
Expand Down

0 comments on commit ae166f7

Please sign in to comment.