Skip to content

Commit

Permalink
Add warning if packages.config is used
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed May 12, 2023
1 parent bebe2df commit 971e368
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/PolySharp.SourceGenerators/PolySharp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
</ItemGroup>
</Target>

<!-- Remove the analyzer if packages.config is used -->
<Target Name="_PolySharpWarnForPackagesConfigUse"
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
DependsOnTargets="_PolySharpGatherAnalyzers">

<!--
Emit a warning in case packages.config is used, by reading the associated MSBuild property.
See https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#restoring-packagereference-and-packagesconfig-projects-with-msbuild.
-->
<Warning Condition ="'$(RestorePackagesConfig)' == 'true'" Text="The PolySharp source generators might not be loaded correctly, as the current project is using the packages.config setup to restore NuGet packages. Source generators require PackageReference to be used (either in a legacy-style or SDK-style .csproj project, both are supported as long as PackageReference is used)."/>
</Target>

<!-- Configure the MSBuild properties used to control PolySharp's generator -->
<Target Name="ConfigurePolySharpMSBuildProperties"
BeforeTargets="PrepareForBuild">
Expand Down

0 comments on commit 971e368

Please sign in to comment.